CS239 Advanced Programming

James Madison University

Software Requirements Specification

Programming Assignment 6 - Parking Cars

Due Thursday, Apr 24 by 10:00pm, cannot be submitted after Friday April 25, 10:00pm

Hardcopy materials due in my office no later than Monday during office hours TBA.


Introduction

Parking is a major problem in many cities.  In this application, you will build an application that will manage a parking lot.  

Purpose:  This application will simulate a parking lot that is bound on three sides by buildings.  The lot is small, 5 lanes at 100 feet each. You must add and remove the cars from one end of the lot only.  Parking the cars involves finding a lane which has enough room for the car and pulling it behind the other cars in the lane.  Retrieving the car involves moving all the cars behind it out, then removing the car that is retrieved, then putting the cars back filling the gap where the removed car had been.  See example in picture.  

Parking Lot pictureParking Lot

When a car is added to the lot, it is assigned a vehicle id (VID) (such as 79).  The owner gets a receipt with that number for later retrieval of his or her vehicle.

When adding a car to the lot, the managers have decided to use a "worst fit" algorithm while the lot is less than 1/2 full.  (The total length of the cars parked is < 250 feet).  When the lot becomes 1/2 full or greater, they switch to a "best fit" algorithm.  Worst fit specifies that given a set of spaces, you will put the object (in this case a car) into the space that is the biggest that will accomodate the object(leaving the largest block of unused space).  Best fit specifies that given a set of spaces, you will put the object (in this case a car) into the space that is the smallest that will accommodate the object (leaving the smallest amount of unused space).

If a car comes to be parked, but there is not enough room to park it, you must turn it away.

The application should keep track of:

Deadlines

Teamwork

This assignment is to be done with your team.  You may collaborate on any aspect of the assignment and frequent collaboration is encouraged.  However, each team member will take responsibility for one aspect of this assignment.  The team reporting sheet will tell me who has responsibility for which part.  The "ownership" pieces are:
For teams with 4 or 5 people:
In all cases, you should acknowledge in all files who worked on that particular file either through the author tag or the acknowledgements section.

Input

A menu will control the action.  See the output section for what the menu will look like.  Users will enter a number to identify an action to take, Park a car, Retrieve a car, Show lot, or Exit.

Park a car: When the user chooses to park a car, the user will enter:
Retrieve a car: When the user chooses to retrieve a car, the user will enter:
Show lot: There is no input to Show lot

Exit: When the user chooses to exit, the user must confirm by typing Yes, yes, Y or y.

Output 

Menu

1. Output a welcome message, "Welcome to the Parking Lot Manager".  This should be followed by a blank line.
2. Output the menu.
Choose an option from this menu:
    1. Park a car
    2. Retrieve a car
    3. Show lot
    4. Exit
    Each menu option should be indented one tab space.  The Choose ... line should be flush with the left hand margin.
3. On the line immediately following the menu, output "-->" and this should be flush with the left hand margin.  The cursor should remain to the right of the arrow.
4. Output a blank line immediately following entry of a value and before printing any other output.

Park a car

  1. Output the prompt: "License number: " .  The cursor should remain on the line beside the prompt awaiting entry.
  2. On a new line output the prompt: "Length: ".  The cursor should remain on the line beside the prompt awaiting entry.
  3. On a new line output the prompt: "Description: ".  The cursor should remain on the line beside the prompt awaiting entry.
  4. Output a blank line.
  5. If there is room for the car, output the vehicle id, the lane number, and the position as follows: "VID-" followed by the assigned number followed by a tab followed by "Lane: " followed by the lane number (1 based) followed by "-" followed by the position (1 based).  Note: Cars are always parked at the end of the available lane.
  6. If there is not room for the car in the lot, see the error message section.

Retrieve a car

  1. Output the prompt, "VID: ".  The cursor should remain on the line beside the prompt awaiting entry.
  2. If the user simply hits the enter key, output the prompt, "License number: ".  The cursor should remain on the line beside the prompt awaiting entry.
  3. Output a blank line before printing any error messages or the location information.
  4. Output the location information as follows: "VID-" followed by the assigned number followed by the vehicle description followed by a tab followed by "Lane: " followed by the lane number (1 based) followed by "-" followed by the position (1 based).  On the next line, output the number of vehicles to move before reaching the designated vehicle, "Move x vehicles", where x is the number of vehicles to move.

Show lot

Display each lane in order (1 - 5) in the following fashion.
  1. On the first line "Lane: " followed by the lane number followed by " " followed by the number of vehicles in the lane.
  2. On the subsequent lines, one line per vehicle, a description of the vehicle: ""VID-" followed by the assigned number followed by the vehicle description followed by a tab followed by "Lane: " followed by the lane number (1 based) followed by "-" followed by the position (1 based).
  3. After all five lanes have been displayed, output a blank line.
  4. Output summary information as follows, each on its own line and each indented by one tab space:
    1. "Current number of vehicles: " followed by the number of vehicles currently in the lot.
    2. "Number today: " followed by the total number of vehicles that were parked in the lot this day
    3. "Turn downs: "followed by the number of vehicles that came but could not be parked.  
  1. Output a blank line.

Exit

Display the message: "Are you sure you want to exit and reset the lot? ".  The cursor should remain beside the prompt.

Errors

Choosing a menu option:
Park a car:
Retrieve a car:
Exit: If the user enters anything other than Yes, yes, Y, or y, redisplay the original menu.

Description of Classes

Thinking about this problem, you have several "nouns" that represent objects in the problem.  Cars, the lot, the lanes are all important features within this program and each has its own job to do.  In addition, you may choose to add additional helper classes.  One recommended class is your IO class.  None of the other classes should do IO directly.

The lanes have one additional requirement.  You MUST implement your lanes using a type-safe linked list of Car objects.  

Additional Program Requirements

  1. Your program must include an acknowledgement section acknowledging help received from TAs or reference sources. You do not need to reference receiving help from the instructor.
  2. If you received no help your acknowledgement section should have a statement to that effect.
  3. Your program must conform to standard Java programming standards and the additional requirements for this class. See the Style Guide for this class.

Test Plan

The test plan is an important part of this assignment.  You should consider all possibilities for how a user might enter data and usual and unusual values for the vehicles entering and leaving the lot.

Honor Code

This work must conform to the JMU Honor Code and the specific requirements of this class. Help may be obtained from other students, but any code that you write must be your own or your group members work.  The names of all contributors to a particular program must be listed in the references or author section. 

Grading

Grading is a little more complex for this assignment.  There will be individual grades and group grades and together they will form your overall grade.