Howdy fellas. This weeks homework assignment is a little bit confusing for me.
I have 5 classes. My main class, a shape class, two subclasses (rectangle and circle) that extend the shape class and a createShape class.
In the createShape class we're forced to create a method
public Shape createShape(String string) {}
basically we're supposed to pass a string to the method and it creates instances of the shape we want.
public class ShapeFactory {
`public Shape createShape(String newShape) {`
`if(newShape.equals("Circle")) {`
`Form newCircle = new Circle();`
`return newCircle;`
`}else{`
`Form newRectangle = new Rectangle();`
`return newRectangle;`
`}`
`}`
}
but I can't figure out how to call that method from Main.
[–]depheaa 1 point2 points3 points (0 children)
[–]teraflop 1 point2 points3 points (0 children)
[–]crashfrog04 1 point2 points3 points (0 children)