Created
April 20, 2014 10:57
-
-
Save mplacona/11111173 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShapeFactory{ | |
IShape getShape(String shapeType){ | |
// check for nulls being passed | |
if(shapeType == null){ | |
return null; | |
} | |
// check for types | |
var type = shapeType.toLowerCase(); | |
switch(type){ | |
case "rectangle": | |
return new Rectangle(); | |
break; | |
case "circle": | |
return new Circle(); | |
break; | |
case "square": | |
return new Square(); | |
break; | |
} | |
// we always return null if there are no matches | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment