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:

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:

  1. Cars are always drawn a fixed size.
  2. Trucks can have an arbitrary length box, as specified by a length parameter.
  3. Trains have an engine and a variable number of boxcars, that are each a fixed length.
  4. 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?
  5. 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.
  6. 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.
  7. The frame must have an aesthetically-appealing layout, using a single flow-layout for the whole frame won't cut it!
  8. 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.
  9. 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

  1. 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.
  2. 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!
  3. 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!