Custom Turtle

Create a project named CustomTurtleRunner that includes a client ("runner" or "test") class named CustomTurtleRunner as well as your own appropriately named custom class (e.g. SquareTurtle) that extends the Turtle class. For the instructor's convenience, even though it is not good style, you should include the custom class below your client class in the same .java source file. See this CustomTurtleRunner demo program as a model for this assignment.

The new class must:

  • include 3 or more additional instance variables
  • include additional "other" constructors that allow the client programmer to initialize the instance variables to non-zero values
  • include accessor methods for each instance variable
  • include modifier methods for each instance variable
  • include 3 or more "interesting" instance methods such as ones that make a turtle move in an interesting pattern. For example, an "interesting" method might be named drawSquare and it could be used to make a turtle draw a square. Or, the interesting method can perform a calculation with one or more of the object's instance variables like exercise that causes a health instance variable to increase.
  • illustrate overloaded methods by having 2 interesting methods with the same name but different method signatures (i.e. different parameter lists.) For example, there could be 2 drawSquare methods such as: void drawSquare() that draws a square in the current pen color and void drawSquare(Color color) that draws a square in the specified color
  • include a static method such as turtlePlague that causes all turtles to turn black.
  • demonstrate that a Turtle object can be passed as a parameter to another method within your new class. That is, one of your "interesting" methods must accept a Turtle parameter so that explicit parameter interacts with the implicit parameter (this) in a meaningful way. For example, the method could be exerciseWithATrainer and cause one object's health to be increased by some proportion of another object's health instance variable.
  • include an appropriately declared and named constant that makes sense in the context of your custom Turtle class

The client class must do the following in sections labelled with the following comments:

  • // SECTION A
    • instantiate 3 or more objects of your new kind of turtle using different constructors
  • // SECTION B
    • use 5 or more interesting methods inherited from the Turtle class such as forward
  • // SECTION C
    • use each accessor method
    • use each modifier method
  • // SECTION D
    • use each interesting method including both versions of the overloaded method
  • // SECTION E
    • use the static method
  • // SECTION F
    • illustrate the concept of aliasing by aliasing two object variables and then break the aliasing bond by re-instantiating one of the object variables with the new operator. Use accessor methods or the toString method to illustrate that they are aliased and then no longer aliased.

Other:

  • Somewhere in either the new class or the client class, you must make use of the constant that was added to the custom Turtle class.
  • All code must follow the class Coding Standards including the use of proper names, coding style, and good documentation.

Here are some resources and examples that may be useful:

You must upload the following files to a location specified by the instructor with your first name and last initial substituted for JohnD:

    1. A copy of the .java source code file named CustomTurtleRunner.java
    2. The source code file saved as a pdf with the name CustomTurtleJohnD.pdf
    3. A cropped screen snapshot of your program's output at the end or during an interesting moment of the program's execution. This file must be named CustomTurtleJohnD.png.
    4. An screencast video of the execution of the program named CustomTurtleJohnD.mp4.