ArrayLists, and Data Files In JAVA

I. The Assignment

The Bashemin Parking Garage contains a single lane that can hold up to ten cars.  Arriving cars enter the garage at the rear and are parked in the empty space nearest to the front.  Departing cars exit only from the front. 

If a customer needs to pick up a car that is not nearest to the exit, then all cars blocking its path are moved out temporarily, the customer's car is driven out, and the other cars are restored in the order they were in originally.  Whenever a car departs, all cars behind it in the garage are moved up one space.

Write a Java program to operate the garage.

The program will read and process lines of input from a file until end-of-file. Each input line contains a license plate number and an operation (ARRIVE or DEPART), separated by spaces.  Cars arrive and depart in the order specified by the input.  Each input operation must be "echoed" to an output file, along with an appropriate message showing the status of the operation.

1.       When a car arrives, the message will include the license number and state whether the car is being parked or turned away because the garage is full.  If the garage is full, the car leaves without ever having entered the garage.

2.       When a car departs, the message will include the license number and the number of times the car was moved.

The number of moves does not include the one where the car departs from the garage, or the number of times the car was moved within the garage. It is only the number of times it was moved out of the garage temporarily to allow a car behind it to depart.

If a DEPART operation calls for a car that is not in the garage, the message should so state.

 II. Specifications

  1. Create separate classes to implement a car and a garage
  2. The Car class will have private instance variables that store the license number and number of times the car has been moved, and any methods you discover to be necessary
  3. The Garage class must use an ArrayList of Car objects to implement the garage
  4. Your Garage class must implement separate methods arrive() and depart(), to handle the arrival and departure, respectively, of a car (in addition to any other methods you may need).
  5. Also write a "test" class that reads the operations from the file and calls the appropriate Garage class method for each.
  6. Make sure your classes adhere to the style and documentation standards discussed in class and in online notes

III. Data File

The input file to be used - garage.txt - is available on the class web page

iV.  What to Hand In

1.   Printouts of all three classes

2    A printout of the output file created

3.   Printouts of the html files generated by javadoc for your Garage and Car classes, but not for your "test" class (never for a test class)

V. What to Upload to Moodle

   Related Questions in Programming Languages

  • Q : Identify Customers in SQL The company

    The company wish to provide an incentive of free shipping to such customers who have not returned for 2 months. Build a procedure named PROMO_SHIP_SP which determines these customers are and then updates the BB_PROMOLIST table accordingly. The procedure employs the be

  • Q : BAT files and shell scripts Using the

    Using the Web as a resource for your investigation, find out and explain what BAT files and shell scripts contain, and what they are used for. In the light of your findings, discuss why an operating system would provide both a graphical user interface

  • Q : Define Zip file Zip file : It is a file

    Zip file: It is a file employed to store compressed versions of the files. In connection with Java bytecode files, such have mostly been superseded by the Java Archive (abbreviated as JAR) files.

  • Q : Define Capability Normal 0 false false

    Normal 0 false false

  • Q : Restrictions implied on API functions

    What are the restrictions implied on API functions?

  • Q : Explain Abstract Windowing Toolkit

    Abstract Windowing Toolkit: The Abstract Windowing Toolkit (AWT) offers a collection of classes which simplify the creation of applications with the GUI (graphical user interfaces). Such are to be found in the java.awt packages. Included are classes f

  • Q : Data structure appears in a COBOL

    The following data structure appears in a COBOL program used by a bureau de change:01 AUXILAIRY-ITEMS.    05 AMOUNT-REQUIRED PIC999V99.    05 SUCCESS-INDICATOR PIC 9.    88 SUCCESS VALUE 1.01 C

  • Q : Define PS3 Debug/TEST/Prototype

    Define PS3 Debug/TEST/Prototype Consoleroduction deployment.

  • Q : What is Bridging method Bridging method

    Bridging method: A method which offers a bridge between methods of a class's public interface and its private implementation. Bridging methods will usually contain non-public visibility.

  • Q : Write a program and estimate pi using

    Consider a dartboard of radius 1. Since the area of the board will be  π r2 = π * 1 *1, it's clear the area of the dartboard is exactly π. The area of a square surrounding the board (circumscribing it) would be 2*2 = 4, sin

©TutorsGlobe All rights reserved 2022-2023.