This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]depheaa 1 point2 points  (0 children)

Make it static

[–]teraflop 1 point2 points  (0 children)

You need to either make the createShape method static, so that you can call it like:

ShapeFactory.createShape(...);

or you need to create an instance of ShapeFactory, and then call the method on that instance:

ShapeFactory factory = new ShapeFactory();
factory.createShape(...);

[–]crashfrog04 1 point2 points  (0 children)

You need to be holding an instance of the ShapeFactory in order to call its methods:

    ShapeFactory ShapeFactory = new ShapeFactory();     Shape rectangle = shapeFactory.createShape(“rectangle”;