Cars, Trucks, Trains!
This is an individual assignment.
Feel free to ask questions of your instructor, student assistants and classmates as desired.
Goals
The goals of this exercise are to:
- Reinforce good object-oriented software design principles and tools: inheritance, UML, and IEPs.
- Gain more practice creating graphical user interfaces.
The Exercise
Instructions Part 1 - Basic Specification
This simple program can draw cars, trucks, and trains on a panel using Java's simple commands in the Graphics class, like
drawOval(), fillOval, and drawRect().
Details:
- Cars are always drawn a fixed size.
- Trucks can have an arbitrary length box, as specified by a length parameter.
- Trains have an engine and a variable number of boxcars, that are each a
fixed length.
- The user specifies the direction (facing left or right), position (x,y),
length of container (for trucks), and number of boxcars (for trains). You get to choose how
the user will input these, but perhaps some methods are nicer than others?
- There will be some way (buttons?) to add each of the vehicles (using whatever parameters
have been chosen), and a way to create
a random vehicle with whatever (reasonable, random) parameters are needed for
that vehicle.
- You must make use of inheritance: you will have an abstract Vehicle class
that contains as many methods and fields that are common to all these vehicles.
Then each specific vehicle class must contain a draw() method that when called,
adds it to the current method.
- The frame must have an aesthetically-appealing layout, using a single
flow-layout for the whole frame won't cut it!
- The vehicles must be stored the vehicles in a Vehicle array so that if the user
resizes the window, all the vehicles will be redrawn again.
- You are not constrained to use art like my figures.
Your drawings must be constructed from primitives line lines and polygons (no images).
They must be roughly as detailed as mine. The more artistically-inclined among us can add more detail,
but if you do, leave enhancements to that last stage of your IEP.
Instructions Part 2 - Design
- Sketch out the layout of your screen. This will help you determine how many components like panels and buttons you will need,
and how you will organize them into panels and subpanels.
- Create a UML diagram for the project. Use the good instructions that Jason posted to the forum:
focus on interactions and add in the key methods and fields you will need. You
will turn in your UML to the assistants in class, like we did for Fifteen, only
this time you will be graded. Be sure you use correct symbols!
- Create an iterative enhancement plan (IEP) for the project and submit it in your
project folder.
Instructions Part 3 - Start coding according to your IEP.
Start by creating a project called CarsTruckTrains and adding it to your personal repository.
Commit your project to your repository at least when you finish every stage of
the IEP.Don't forget to commit your final project!