Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having trouble with a section of code for a simple drawing program in java.

ID: 3846371 • Letter: I

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 code:

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.

The group class's code:

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

Explanation / Answer

The class Size can be like the following :

Within the Test class there has to be a function which uses the assertion to return appropriate values .Lets say

it is : int assertSize(Shape s ) { // code for assertion return depending upon Shape passed to it }

Class Size {

private fixtures f ; // Can be initialized using a constructor

private int total = 0 ;

int findSize(){

Test T = new Test();

// As the fixtures class has 3 Shapes of static final Type

total += T.assertSize(f.simpleGroup);

total += T.assertSize(f.middleGroup);

total += T.assertSize(f.complexGroup);

return total ;

}

}