CS111 Lab Recursion Programming Problems

EiffelWorld

In EiffelWorld, EiffelBuilders build Eiffel Towers. We can specify the initial size of the Eiffel Towers (ie the length of one side), the shrink factor for each successive level, the angle of the structure, the number of levels to build, and how far apart (the offset) the levels of the Eiffel tower should be. When we create an EiffelBuilder ellie, she starts at a specific place with her pen down and facing the top. If we ask her to build an Eiffel tower with fewer than one level, she does nothing. She builds a one level Eiffel tower with the tip at her starting position. Regardless of the number of levels in the Eiffel tower she builds, ellie stands in her initial position facing her initial direction when she is finished. The following pictures illustrate the result from asking ellie to build Eiffel towers with different numbers of levels.


ellie.eiffelTower(
64, 0.5, 120, 1, 30);


ellie.eiffelTower(
64, 0.5, 120, 2, 30);


ellie.eiffelTower(
64, 0.5, 120, 3, 30);


ellie.eiffelTower(
64, 0.5, 120, 4, 30);

Our task is to fill in the code for the eiffelTower method in the EiffelBuilder class. The following skeleton is provided for us.

   
public void eiffelTower (double size, double shrinkFactor,
   
                         double angle, int levels, double offset) {
   
  System.out.println("eiffelTower("+size+", "+shrinkFactor+
   
                     ", "+angle+", "+levels+", "+offset+");");
   
  // add your code here
   
}
   
   

We may also want to define auxiliary methods in the EiffelBuilder class. We should not need to modify the EiffelWorld class in order for our code to work. However, we may modify it during testing.