Assignments Overview
Big picture: In the series of assignment you will create a simulation of a natural
world with animals (birds, fish, insects, mammals, etc) that move, eat, die and
predators that hunt them. We will finish with simulating some flocking behavior. and
build some smartness into the simulation. In the process, you will learn Java and
object oriented programming, and get plenty of practice opportunities.
Choose a kind of animal world you will build a simulation of. As we progress, you
will have to draw your animals, their predators, their food, and features of the
environment.
A4: Phase 1 requirements
Create a control panel for your simulation. The control panel should show the
internal data for your selected animal or predator, such as location, energy level,
speed. You should be able to select and deselect the animal/predator using
mouse. Selected animals should be drawn highlighted (any way you choose). The
data in the control panel should be continually updated.
There should be the segment of the control panel that provides updates on the
application as a whole and allows you to control some high-level parameters,
such as max number of animals, number of predators, max food size, or similar.
You should have at least three different kinds of action for your application that
you can initiate using the control panel. At least one of those should modify the
individual animal’s behavior, and at least one should affect the application as a a
whole.
You need to refactor your application so you have one class that extends JFrame,
you have another class that extends JPanel for your simulation (as before), and
you have one class that extends JPanel and contains Control Panel. You will
continue to have classes for your animals, predators and food.
Control panel should be added into the same frame. together with your
simulation panel.
Bonus (1 point): you should be able to dynamically show/remove the control panel
using some key combination.
Complex GUI
Your starting point is an environment with all implemented mandatory
functionality up to the A4P1. If you haven not implemented some of the
functionality, you have to complete it for this assignment.
This goes beyond the Control Panel that you have done in Phase 1. It should
include capabilities to control every aspect of the application, including
controlling the number of animals, animal generation parameters, food
generation, predators, setting/controlling the max values for speed and energy
levels, and other parameters around how you compute forces etc. You need to
design a series of dialogs and menus to create a GUI. You also need to include
the menubar with menus that will allow you controlling each kind of object
specifically, e.g. menu for Animal, menu for Predator, menu for Food. Items in
menus should allow you to control aspects related to each class for existing
objects. You should also have a “Properties…” menu item that will open a dialog
box that will allow you to change the properties for the next new generated
animal/predator/food, i.e. you need to have three dialog boxes.
You will need to refactor your code so you eliminate the fixed values for
parameters you used to generate animals. For example, you may have used
minimum and maximum fixed values for the lover and upper limit for your
random number generator for animal size. Instead, now you will have these two
parameters that can be modified in via the dialog window.
There is a tutorial for building
GUI: https://docs.oracle.com/javase/tutorial/uiswing/components/index.html (Links
to an external site.)Links to an external site.
If you go to the very top of the tutorial, it tells you to use Netbeans IDE for
building GUI. Creating graphical layout might be faster, but you have to modify a
lot of code in generated code, which is confusing. I suggest that you build from
scratch, you can find snippets of code how to do certain things (reference code
you found), but you will still have to connect it to your reworked code of your
simulation.
Complex GUI (Total: 16 points max)
1 pts Menu bar with menus for each object
3 pts Menu items control behaviour of selected object, all objects of a certain type,
or simulation as a whole
4 pts Properties dialog to set the parameters for each kind of object (animal,
predator, food) and for the simulation
2 pts Values set in properties dialogs saved to a file and restored when simulation
runs next time
2 pts Use a variety of widgets in the dialog boxes to specify values (at least three
different kinds): textboxes, checkboxes, combo-boxes, lists, etc.
3 pts Control panel updated to control/monitor runtime aspects of the objects and
simulation
1 point Report BUT...
Note: All implemented functionality as per above has to be clearly documented in
the report in addition to specific comments in your code comments. What is not
documented in the report does not exist, i.e. will not get marked.
Suggestions: use the marking criteria below as a structure for your report.
Report: 2 pages max, single line spacing, 1” margins, 12pt font
up to minus 4 points
Mandatory functionality from prior assignments missing