Cars, Trucks and Trains!
CSSE 221 – Fundamentals of Software Development Honors
Fall 2008–2009

Work on this exercise with a partner, using pair programming. Both partners should participate fully in ALL aspects of the project.

Goals

The goals of this exercise are to apply and hence reinforce your understanding of:

Overview

You will design and implement an application that has all the functionality suggested by the picture to the right. (Click here for a full-sized picture.)

  • You will implement by using:
    • pair programming
    • documented stubs
    • an iterative enhancement plan
  • Deliverables, as described below, include a UML class diagram, an iterative enhancement plan with dates, html javadoc-generated documentation, and your code. There is no report associated with this project.
Solved CarsTrucksTrains project

Specification

  1. Basic functionality: Your program must be able to display cars, trucks and trains, as follows:

    1. Vehicles are drawn as stick-figures (no images).
    2. The user can add cars, trucks and trains to the display, by using the user interface described below.
      • Once added, a vehicle must remain displayed (even if the application is minimized and then maximized, for example).
      • The user interface also allows the user to place a random vehicle with whatever (reasonable, random) parameters are needed for that vehicle.

    3. All cars have the same size, as follows:
      • Body (bottom rectangular box) is 80 by 20.
      • Interior (top rectangular box) is 30 by 16.
      • Car wheels have diameter 16.
      • Choose any reasonable placement of interior on top of body and 2 wheels below body -- exact placement is not important.
    4. For trucks:
      • The cab (front part of the truck) is 20 by 45.
      • The length of the container (rectangle behind the cab) is arbitrary (user-specified).
      • The height of the container is 60 (no matter how long the container is).
      • Truck wheels have diameter 20.
      • Choose any reasonable placement of 4 wheels below the container and 1 wheel below the cab -- exact placement is not important.
    5. For trains:
      • The engine body is 120 by 30.
      • The engine smokestack (tall rectangle on top of engine body) is 20 by 45.
      • The engine cab (long rectangle on top of engine body) is 60 by 30.
      • Each boxcar is 150 by 60.
      • The number of boxcars is arbitrary (user-specified).
      • Train wheels have diameter 20.
      • Choose any reasonable placement of smokestack and cab on top of the engine body, and any reasonable placement of 4 wheels below the engine and 4 wheels below each boxcar -- exact placement is not important.

    6. Per the user interface described below, the user specifies:
      • the direction (facing left or right)
      • position (x,y)
      • length of container (for trucks)
      • number of boxcars (for trains)

  2. User interface: The user interface must be as pictured above. Ask your instructor if you have questions about the user interface.
  3. Platform. Your program must be able to run as either a Java Application or a Java Applet.
  4. Implementation requirements. Your program must:

    1. Make good use of inheritance and polymorphism. In particular:
      • You must have a Vehicle class with subclasses Car, Truck and Train.
      • Your vehicles should be stored in a single list of Vehicle objects (instead of having separate lists for Cars, Trucks and Trains).
      • Each Vehicle subtype should have a draw(Graphics) method that draws that type of Vehicle.
      • Data and functionality common to the Vehicles should be placed in the Vehicle class.
    2. Use Swing components
    3. Have a clearly documented, object-oriented design that could be easily extended to incorporate additional features
    4. Have code that is clear, is easily extended, and obeys Sun's code conventions
      • In Eclipse, Source ~ Format enforces these code conventions
      • Also choose appropriate names for variables and classes
    5. Be reasonable in its use of space and time
    6. Be implemented by using documented stubs and pair programming and an iterative enhancement plan.

  5. Additional functionality. You may implement additional features if you wish, but you receive full credit simply for the above and extra functionality will not earn any extra points.

Deliverables and Turning in your work

Recall that you work in pairs on this project. Let xxx denote one partner's username and yyy denote her partner's username, where xxx is alphabetically before yyy.

Your instructor created a repository whose name is:
	csse221-200910-CarsTrucksTrains-xxx-yyy

You should place the following into that repository:

  1. A folder called CarsTrucksTrains that is your Eclipse project.
  2. A PDF document called CarsTrucksTrainsUML that is your UML class diagram.
  3. A PDF document called CarsTrucksTrainsIEP that is your iterative enhancement plan (IEP), with completion dates placed beside each stage.

All of the above should be committed frequently, so that we can observe the progress of your project as you work on it.

You may have additional documents in your repository if you wish, for example a UMLet or Violet class diagram and a Microsoft Word iterative enhancement plan, but we will examine only the PDF documents and your Eclipse project.

Grading Rubric

Item Maximum points lost if unsuccesful at the item
Can add a car that is displayed correctly 10 points
Can add a truck that is displayed correctly 10 points
Can add a train that is displayed correctly 10 points
Vehicles can be placed per the specified user interface 20 points
Trucks' container-lengths can be set per the specified user interface 10 points
Trains' number-of-boxcars can be set per the specified user interface 10 points
The direction of vehicles can be set per the specified user interface 10 points
Inheritance and polymorphism are used per the specification 20 points
Your code is clear, is easily extended, and obeys Sun's code conventions, per the specification 10 points
Your code is documented appropriately, including generating Javadoc, per the specification 10 points
You have an object-oriented design — described clearly, completely and accurately by your UML class diagram — that could be easily extended to incorporate additional features 20 points
You implemented your project by using documented stubs and pair programming and an iterative enhancement plan 20 points

Your grade for this project is computed by starting at 110 and subtracting points for each item above at which you were not successful. Thus, your grade can be as high as 110% (yes, that is more than 100%) or (in theory) negative.