subject

A parking garage consists of several levels with many parking spaces on each level. A garage management program keeps track of the number of cars parked in the garage and helps to find the location of a car with a given ID. Consider the following three Java classes used in this program. The class Car represents an individual car: public class Car // returns the id of this car public String getID) { /* implementation not shown */) // private data, constructors, and other methods not shown The class Parking Level represents one level of the garage: public class Parking Level // returns the number of parking spaces on this level public int numSpaces() { /* implementation not shown */ ) W returns the car parked in the space number spaceNum W or null if that space is empty public car getcar(int spaceNum) ( 7 implementation not shown * W returns the smallest space number of an available space or 11 -1 16 the level is full and there and no empty spaces public int findEmptySpace () / implementation not shown) 1/ marks space number spaceNum on this level as occupied W by car vi i v- null the space is marked as empty // precondition: space number spaceNum 18 empty public void setCar(int spaceNum, Car v) (7. implementation not shown * // private data, constructors, and other methods not shown A Parking Level object keeps track of the cars parked within its spaces as well as empty spaces. The parking spaces on each level are numbered by consecutive integers, starting from 0. The ParkingGarage class keeps track of all the levels in the garage. It keeps the information about the levels in an array of ParkingLevel objects. public class ParkingGarage private int totalCars; // total number of cars in this garage private ParkingLevelll levels; // each element corresponds to a level in the garage // returns true if there are no available spaces on any 1 level within the garage; otherwise, returns false public boolean is Full() { /* implementation not shown */) 1/ returns true if a car with a given ID is already parked somewhere in the garage; otherwise, returns false public boolean isCarAlreadyParked (String id) { / Implementation not shown */ } // if the garage is not full and no car with the same ID // as v's ID is in the garage yet, parks Car v into the // garage, updates the number of cars parked in the // garage, and returns true; otherwise, leaves the garage // unchanged and returns false public boolean parkCar (Car v) ( * TO BE IMPLEMENTED */ } private ParkingLevellevels; . W/ each element corresponds to a level in the garage // returns true if there are no available spaces on any // level within the garage; otherwise, returns false public boolean isFull) { /* implementation not shown */) V/ returns true if a car with a given ID is already parked W somewhere in the garage; otherwise, returns false public boolean isCarAlreadyParked (String id) { /* implementation not shown // if the garage is not full and no car with the same ID // as v's ID is in the garage yet, parks Car v into the // garage, updates the number of cars parked in the // garage, and returns true; otherwise, leaves the garage // unchanged and returns false public boolean parkCar (Car v) { /* TO BE IMPLEMENTED */ } // if a car with a given ID String id is found, removes // that car, updates the number of cars parked in the garage // and returns the found car; otherwise, leaves the garage // unchanged and returns null // precondition: id is not null and is a non-empty string public Car removeCar (String id) { /* implementation not shown */ } 77 private data, constructors, and other methods not shown. (QUESTION) Write the parkCar method of the ParkingGarage class. If the parking garage is not full and if the car is not already in the garage, then the car should be parked in an empty space, the number of cars in the garage should be updated. and the method should return true, indicating successful parking. Otherwise, the garage data should remain unchanged and the method should return false, indicating that the car was not parked. In writing parkCar, you may call any accessible methods in the car and ParkingLevel classes. Assume that these methods work as specified Complete method parkCar below. // if the garage is not full and no car with the same ID // as v's ID is in the garage yet, parks Car v into the // garage, updates the number of cars parked in the 1/ garage, and returns true; otherwise, leaves the garage // unchanged and returns false public boolean parkCar (Carv)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 22:50
What is an rss reader used for? for creating a user account on a social new site
Answers: 2
question
Computers and Technology, 24.06.2019 03:00
Click the "draw structure" button to activate the drawing utility. draw two diastereomers of (1z,4r)−1,4−dimethylcyclodecene and name them, including (e)/(z) and (r)/(s) notation. part 1 out of 4 draw the diastereomer containing a chiral center with s configuration here. window open
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
To fill (copy) a cell across or down, point to the of the cell and drag. top left corner top right corner bottom left corner bottom right corner
Answers: 3
question
Computers and Technology, 24.06.2019 20:10
Approximately what portion of global employers tends to use social media websites to hire new employees?
Answers: 1
You know the right answer?
A parking garage consists of several levels with many parking spaces on each level. A garage managem...
Questions
question
Mathematics, 22.09.2020 22:01
question
Computers and Technology, 22.09.2020 22:01
question
Mathematics, 22.09.2020 22:01
question
Chemistry, 22.09.2020 22:01