Homework #1: Program Turtle methods
Objectives
The objectives of this assignment are to have you define your own Java methods to add to the basic behavior of the Turtle Java class. You will write Java methods with and without parameters. You wil then write a Java main program to call on those Java methods to draw connected multifaceted geometrical shapes that you have designed.
Problem
- Design the shapes you want drawn. You should have a minimum of 10 different shapes that are connected to create a large multifaceted shape -- a building for example. The design can be done by hand. You must turn in your design by Wednesday February 20th
- Define and write methods for the Turtle class. At a minimum, you should include the following methods:
- The three methods to draw squares given in the textbook
- A method to draw a rectangle of a specified width and height (e.g., the Turtle can be asked to draw rectangles of different dimensions by a call to the same method)
- A method to draw a diamond of a specified length (e.g., the Turtle can be asked to draw diamonds of different lengths)
- A method to draw a hexagon of a specified length and color (e.g., the Turtle can be asked to draw hexagon of different lengths and colors).
- Three other methods to draw shapes of your own choosing. All methods must be flexible to allow the shape to be drawn in different sizes, or line thickness, or pen color.
- Write a Java program (e.g. one with a class method named main()) that does the following:
- Creates a World for the turtles (alternatively, you are encouraged to use a Picture instead)
- Creates at least two Turtles in the World (or Picture)
- Uses variables to keep track of pen widths, pen colors, shape lengths.
- Calls methods on each of the three Turtles to create a multifaceted geometrical shapes on the World (or Picture). For example, you could draw multiple cabins in a beach picture along with sea stars or draw a blueprint of your dream home.
- Moves the turtles to different locations in the World (or Picture) and changes their orientation in order to draw the shapes as desired.
- Draws shapes by changing the default behavior of each Turtle object. For example, you can change the color and thickness of the pen used in drawing the shapes.
- Makes non-trivial use of the following Turtle methods: penDown(), penUp(), setHeading(), turnToFace().
Deliverables
You must submit the Java code in printed form and electornically -- see below.
You must also demonstrate your working program during lab time on the due date. To
submit your code electronically, send via e-mail the files Turtle.java and also your
Java main program (call it what you like, as long as it's a good name). Your code
must compile and run in the CECS lab computers without any changes!
Notes