Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 echo printed 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

  1. 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

  1. To get credit, your Garage class must use an ArrayList (not an array) of Car objects to implement the garage. No credit will be given otherwise

  1. Use a defined constant to set the capacity (i.e. number of spaces) of the garage. The literal 10 should not appear anywhere else in your program

  1. To handle the arrival and departure of each car, your Garage class must implement separate methods arrive() and depart(), each of which returns a String showing the result of the operation (see above)

  1. Your garage class may contain other methods should you find them necessary or advisable

  1. Also write a test class that reads the operations from the input file, echoes each to the output file, calls the appropriate Garage class method, and writes the String returned to the output file

  1. As stated in 5. and 7., above, all output is to be done in the test class. None of the Garage or Car class methods do any output

  1. Make sure your classes adhere to the style and documentation standards discussed in class and online notes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

Students also viewed these Databases questions

Question

Use the graph of g to find g(4)

Answered: 1 week ago

Question

5. Recognize your ability to repair and let go of painful conflict

Answered: 1 week ago