CSCI 235 Spring 2015
Data Structures and Software Design
Archived Class
Charles Cusack
Computer Science
Hope College
Main
Schedule
Grading
Gradebook
Homework
Links

Policies
College
    Policies
Advice

Notes
Programs
Tutorials

CSCI 125
CSCI 255
MATH 341
Others

Admin

Homework 6

Details

For this assignment you will improve the Foxes And Rabbits simulation from Homework 5 by adding more buttons. The application should have the following things.

  • One button that will run 1 step of the simulation.
  • One button that will run 100 steps of the simulation.
  • One button that will run the long simulation.
  • One button and associated text field to allow the user to specify the number of steps to run. You should deal with potential errors with what the user puts in the text field.
  • One button that will reset the simulation.
  • A JMenuBar which contains
    • "File->Exit" which exits the application
    • "Help->About" which gives information about who wrote the application, etc. (use the JOptionPane.showMessageDialog method for this).

To keep the simulation from being buggy, you should disable all of the buttons while the simulation is running. Note: You can't just disable them at the beginning of the listener and re-enable them at the end because the simulation is run in a different thread and the listener will return almost immediately. But you can disable/re-enable them at the beginning and end of the run method in the thread. However, if you want to keep Reset enabled during a run so that it will stop the current simulation and reset it, you will also need a boolean field and related code in several places to deal with this.

The application should quit properly when the "X" in the upper right corner is clicked. This is properly implemented in my version of the code, but if you move the main JFrame somewhere else, you will have to make sure you copy the WindowListener code.

You should continue with your code from Homework 5. Note: In this version Simulator and SimulatorView have been slightly modified to make it a bit easier (the version in the book was not designed to make adding buttons easy). I should also point out that this code is based on an earlier addition of the textbook so the code may have other differences.

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

  • Allow the user to select parameters of the simulation like board width and height, and creation probabilities. When the user hits reset, the newly generated board will be based on these parameters.
  • Allow the user to select the stats for each creature, including max age, max litter size, etc. This will require modifying the code for Rabbit and Fox, among other things.
  • Allow the user to click on the squares to place rabbits, foxes, etc. One way to do this is to have each click rotate around the options (rabbit->fox->hunter->empty->rabbit...).

Grading

CriteriaPoints
Correctness10
Design10
Style/Documentation5
GUI/Interface5
Total30
Bonus5

Handing it in.

  1. Fill in the details of the MyGrade-HW6.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.
  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.
  4. Use Webhandin with assignment 235-HW6 to submit the zipfile you just created.