This programming assignment continues the theme from assignments 1 and 2.
In this assignment, you will provide a graphical user interface to the
agent simulation.
Just like Assignment 1, agents are placed
in a grid at starting locations, and are given destination locations.
The agents move as before trying to reach their destinations.
Again, the simulation stops when all agents have reached their
destination or some agents remain irretrievably stuck.
For this assignment, we will disregard horsepower (In other
words, all agents will have horsepower "1").
Also, unlike other assignments, you will NOT be estimating anything
in this assignment.
Create a graphical user interface with the following features:
- A frame that displays the grid. Read in the values of
M and
and N
from the screen. You don't have to use a textbox - just the plain
reading from the screen that you learned in Module 3. But if you
want to use textfield's or textboxes, that would be fine.
- The following buttons:
- A "quit" button to quit the program.
- A "nextAgent" button that moves the next agent.
- A "nextStep" button that moves all agents (that can be moved)
in one time-step. Thus, clicking multiple times on "nextAgent"
will eventually result in the same configuration as "nextStep"
(after all agents have been processed in a single timestep).
- A "completeRun" button that completes the current run.
- A "startNewRun" button that starts a new run with new
random initial locations.
- Display the following data:
- Where appropriate, highlight the agent currently being moved with a
different color.
- Display the ID (number) of each agent. You could, for
example, draw a colored circle to represent an agent, and write
the agent-number inside the circle.
- At the end of a run, use a unique color to depict "stuck"
agents.
- Somewhere on the frame, display the number of agents (a sort
of "counter") that have reached their destination.
Deliverables:
- Write your code in a file called Assign3.java.
- Provide the source code for your program. NOTE: It is not necessary
to write all your all your code in the
same file. In fact it is better to place each appropriate class
(from Assignment 2, if you wish to use those) in a separate file.
Just make sure your main method is in
Assign3.java.
- What did you do to ensure that your code is working correctly?
You will also need to provide some evidence, test cases (and output)
to validate your program.
- Make sure you try your program with M=4 (side of grid) and N=8 (agents).
- Your code will be graded
on both correctness and documentation.
Submission:
- The name of subdirectory for this exercise should be: your username
followed by _a3.
,
- Follow the
submission instructions carefully as usual.
- Submit a printout (hardcopy) of your code before
the due date in my mailbox.