In NestedPolygonWorld
, PolygonBuilder
s
build nested polygon patterns. We can specify the size of the
polygon (ie the length of one side -- all sides are the same length)
and the number of polygons to nest. When we create a
PolygonBuilder
polly, she starts at a specific
place with her pen down and facing the right. If we ask her to build
fewer than one polygon, she does nothing. She builds her first
polygon (an equilateral triangle) with the bottom left corner of the
polygon at her starting position. Regardless of the number of
polygons she builds, polly stands in her initial position
facing her initial direction when she is finished. The following
pictures illustrate the result from asking polly to build
different numbers of polygons.
|
|
|
|
Our task is to fill in the code for the
nestEquiPolygons
method in the
PolygonBuilder
class. The following skeleton is provided
for us.
public void nestEquiPolygons (double size, int number) { System.out.println("nestEquiPolygons("+size+", "+number+");"); // add your code here }
We may also want to define auxiliary methods in the
PolygonBuilder
class. We should not need to modify the
NestedPolygonWorld
class in order for our code to work.
However, we may modify it during testing.
Note: Be sure your code works with numbers higher than 4!
For example, polly.nestEquiPolygons(100, 6);
should give you the picture below: