In this assignment we will add animation using time ticks, some more interactive controls, and better layout to the simulation/game of Assignments 2 and 3, as well as creating a UML diagram.
A good way to handle this kind of simulation is to think of each Vehicle as if it were an independent module. To advance the simulation, your program will call a tick() method for each Vehicle, at regular intervals. The tick method should simply compute a Vehicle's new position, based on its previous position and on its velocity and direction. Different subclasses of Vehicle can move differently, by overloading tick.
We will use a Timer object to keep the simulation running. It will send actionPerformed events to our process, and we will provide a callback routine to be called each time the callback is received. Your callback routine updates the Vehicle locations (by calling tick on each of the Vehicles) and then triggers a repaint of the window.
For this assignment, also submit a UML diagram of your classes and the relationships among them. It should show the main classes in your system, inheritance relationships, and aggregation (containment) relationships -- and collaboration (uses) relationships if you can fit them in.
Don't worry about perfect UML syntax, since it varies. And if the diagram is too complex or too cluttered, you can omit some of the details.
Please submit your diagram in PDF if possible. It can be a PDF printout from a drawing program
or a scan or photo of a handwritten paper document (the copier in the CS department office can
(The rest of this still applies from previous assignments)
Your program design should exploit the features of object-oriented programming (encapsulation of code and data, support for abstract data types, polymorphism/overloading, inheritance). In particular, object-oriented programming provides us a good way to handle the various data needed in callback routines. You should use objects to encapsulate each interactive widget with the routines and data you need to use it.
You should provide an object for each interactive widget or small group of widgets you create. That object should hold anything you need to remember about the widget from one callback to another, all the data pertinent only to the command for that widget or that you need to operate this control, (including, in most cases, a pointer to the map or other outside object to perform the actual action the user requested), and the widget's own listener callback routines.
If you have several widgets that share some behavior or properties, you should organize your objects into an appropriate inheritance hierarchy.
You will have other data that must be accessed by several widgets, particularly shared information about the state of the program or global information about the state of the user interface. Provide additional classes and objects for holding this kind of information.
Remember to trigger your drawing to repaint itself explicitly whenever one of your commands causes a change that should be reflected on the screen. And remember that the way to change the screen is first to change the data stored your classes and then to trigger the repaint.
You should follow these general Java programming practices:
And, finally, on your Java programs, for uniformity, please
name your Java class that has your main program in it
Main, in file
In addition to your program, submit documentation about the design of your system in these forms:
ownwhich other objects)
usesor collaboration relationships (which objects use which other objects to perform functions)
secretsof each of your classes (i.e., what design decisions are entirely encapsulated within that class).
Submit this documentation electronically in text form. Include it as part of the readme file that you submit with your assignment.