Suppose you have the following class hierarchy and a factory in your image viewer application.
interface Shape {
// fields and methods
}
class Circle implements Shape {
// fields and methods
}
class Polygon implements Shape {
// fields and methods
}
class ShapeFactory {
public Shape getShape(String type) {
type = type.toUpperCase();
switch (type) {
case "CIRCLE":
return new Circle();
case "POLYGON":
return new Polygon();
default:
return null;
}
}
}
Choose all working ways to get an instance of Polygon in this application.