-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapeFactory.java
More file actions
30 lines (28 loc) · 1.14 KB
/
Copy pathShapeFactory.java
File metadata and controls
30 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import javax.swing.JOptionPane;
public class ShapeFactory
{
public static Shape createNewShape(ShapeManager shapeManager, Point point)
{
ShapeID shapeID = shapeManager.getCurShapeID();
if (shapeID == ShapeID.RECTANGLE)
return (Shape) new Rectangle(shapeManager, point);
else if (shapeID == shapeID.DOT)
return (Shape) new Dot(shapeManager, point);
else if (shapeID == ShapeID.SEGMENT)
return (Shape) new Segment(shapeManager, point);
else if (shapeID == ShapeID.SQUARE)
return (Shape) new Square(shapeManager, point);
else if (shapeID == ShapeID.OVAL)
return (Shape) new Oval(shapeManager, point);
else if (shapeID == ShapeID.CIRCLE)
return (Shape) new Circle(shapeManager, point);
else if (shapeID == ShapeID.FREEHAND)
return (Shape) new Freehand(shapeManager, point);
else
{
JOptionPane.showMessageDialog(null, "Unrecognized Shape ID!");
System.out.println("Unrecognized shape type!");
}
return null;
}
}