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 https://bitbucket.org/ferzle/foxesandrabbits3
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!):
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.
- In Windows Explorer, right click on the Foxes and Rabbits 3 folder and select Send to-->Compressed (zipped) folder.
- Name the zipfile whatever you wish and make sure it is a .zip file and not some other format.
- Use Webhandin with assignment 235-HW5 to submit the zipfile you just created.
Here is a more detailed breakdown of the grading criteria:
You might also want to know common reasons for miscellaneous deductions:
|third creature works
|third is not animal
|third different than others
|Actor class implemented and used
|fields and methods properly placed in hierarchy
|no unnecessary special code (e.g. in simulateOneStep)
|cohesion (no weird methods or fields)
|no unnecessary code duplication
|Javadoc for all classes/methods
|documentation in code where necessary
|good class, method, field names
|code organized, extraneous code removed
|Total Style and Documentation
|4th unique creature (bonus) up to
|improved graphics (bonus) up to
|Total Bonus up to
Here are some of the common mistakes related to the main grading criteria that past students have made:
- 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)
- 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.