CSCI 235 Spring 2018
Data Structures and Software Design
Archived Class
Charles Cusack
Computer Science
Hope College



CSCI 112
CSCI 125


Homework 5


The next two assignments will be related to the Foxes And Rabbits simulation. In this assignment you will add a third creature. In the next assignment you will improve the GUI. You can see an example of what a finished Homework 5 might look like by downloading and running FoxesAndRabbitsAndSasquatch.jar. (There is only 1 Sasquatch and he eats everything around him. As you can see by running this, he doesn't really affect the simulation much.)

For this assignment you will improve the Foxes And Rabbits simulation by adding another creature.

The third creature must not be another animal (i.e. it cannot be a subclass of Animal), and you should try to think of a creature that will affect the simulation in some significant way. You should perform some of the suggestions from the textbook to create an Actor class, refactor the code accordingly, and add your third creature. Some ideas for creatures include a human, a virus, a dragon, weather, fire, etc. It must act different than both the fox and the rabbit in some significant way (e.g. never dies, doesn't breed, kills everything within 1 or 2 squares (but as Sasquatch demonstrates, having one such creature is boring), kills everything in its row and column, teleports, etc.).

If you did a similar assignment to this in CSCI 225, you should implement a different sort of creature for this assignment and you should not use any of that code. You will learn more this way, and isn't that the point?

Start with the code in the FoxesAndRabbits3 project. That is, fork the repository at and use SourceTree to checkout your forked copy of the project. Then import it into Eclipse. See This video for a reminder of how to do this (using the above URL instead of the one in the video).

Note: This code is based on an earlier addition of the textbook and has been modified to make the next assignment easier.


  • Use what you have learned about inheritance and polymorphism to implement this properly.
  • Do not just sit down and start programming—it will be much easier to implement if you first sit down and think about design.

For more of a challenge (and bonus points), do any of the following:

  • Make the drawing of the simulation a bit fancier. You can draw actual foxes and rabbits, or use little circles for bunnies and triangles for foxes or something similar.
  • Add a fourth creature that is significantly different than the others.

Your grade will be based on:


Hand it in as follows (points will be deducted if you deviate from these instructions!):
  1. Fill in the details of the MyGrade-HW5.txt file in your project (double-click it to edit it) with your self-evaluation. Make sure you provide the total (out of 30) and a justification for each category. Your justification should be more than one or two sentences but less than half a page. Also include a very brief description of the creature you added.
  2. In Windows Explorer, right click on the Foxes and Rabbits 3 folder and select Send to-->Compressed (zipped) folder.
  3. Name the zipfile whatever you wish and make sure it is a .zip file and not some other format.
  4. Use Webhandin with assignment 235-HW5 to submit the zipfile you just created.

Here is a more detailed breakdown of the grading criteria:

third creature works 2
third is not animal 3
third different than others 2
program runs 3
Total Correctness 10

Actor class implemented and used 2
fields and methods properly placed in hierarchy 2
no unnecessary special code (e.g. in simulateOneStep) 2
cohesion (no weird methods or fields) 2
no unnecessary code duplication 2
Total Design 10

Javadoc for all classes/methods 3
documentation in code where necessary 2
good class, method, field names 2
code organized, extraneous code removed 3
Total Style and Documentation 10

4th unique creature (bonus) up to 2
improved graphics (bonus) up to 3
Total Bonus up to 5

You might also want to know common reasons for miscellaneous deductions:
  • Not following the directions for how to zip up and submit code. (-1 or -2)
  • No description of 3rd creature in MyGrade-HW5.txt and/or MyGrade-HW5.txt not filled out or lacks enough detail. (-2 or -3)
Here are some of the common mistakes related to the main grading criteria that past students have made:
  • The fact that everything will probably implement location stuff the same way may suggest an abstract class.
  • Your third creature is virtually identical to Animal--it has all of the same fields and methods. Thus you didn't really implement something different than an Animal, you just put is somewhere else in the hierarchy and duplicated code.
  • Your third creature is almost identical to Rabbit and/or Fox.
  • Special cases for your third creature in simulateOneStep may indicate a design problem.
  • Since your creature can't die, why is setDead in Actor?
  • Since your creature can't age, why are the age related methods in Actor?
  • Don't leave old documentation in your files. For instance, if you copy a class, update all of the documentation. Add your name to classes you created. Do not include the name of the textbook authors in classes you created.
  • Remember to use Javadoc comments for every class and every method.