Question: I am having trouble with a section of code for a simple drawing program in java. I have a class called fixtures that has the

I am having trouble with a section of code for a simple drawing program in java. I have a class called "fixtures" that has the code:

public static final Shape simpleGroup = new Group( new Location(200, 100, new Circle(50)), new Location(400, 300, new Rectangle(100, 50)) ); public static final Shape middleGroup = new Location(50, 100, new Group( new Outline(new Rectangle(50, 30)), new Group( new Circle(20), new Rectangle(50, 30) ) ) ); public static final Shape complexGroup = new Location(50, 100, new Group( new Circle(20), new Rectangle(100, 200), new Location(150, 50, new Stroke(Color.RED, new Fill( new Group( new Rectangle(50, 30), new Outline(new Rectangle(300, 60)), new Stroke(Color.CYAN, new Polygon( new Point(50, 50), new Point(60, 100), new Point(100, 110), new Point(120, 60) ) ), new Location(100, 200, new Stroke(Color.MAGENTA, new Outline(new Circle(50)) ) ) ) ) ) ) ) ); 

I then have a class called "size" that is supposed to count the number of objects in fixtures. I have a test class that asserts that groupsimple returns 2, groupmiddle returns 3, and groupcomplex returns 6. I am supposed to fix the size code, but I cannot figure it out.

@Override public Integer onGroup(final Group g) { return null; } 

The group class's code:

public class Group implements Shape { protected final Listextends Shape> shapes; public Group(final Shape... shapes) { this.shapes = Arrays.asList(shapes); } public Listextends Shape> getShapes() { return Collections.unmodifiableList(shapes); } @Override public  Result accept(final Visitor v) { return v.onGroup(this); } 

There are more classes involved, but I think this should be enough to show my point. Any help would be greatly appreciated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!