Write a CarParking class to model a multistory car parking building. This class should contain a 3- dimensional array of type Vehicle. The third dimension of the array simply represents the number of floors of the building while the first and second dimensions are the number of rows and columns in every floor. By default, there are 3 floors, 7 rows and 7 columns in a building. However, the user should be able to specify the maximum number of floors, rows and columns at the time of creating a CarParking object. In addition to the constructors, this class should provide the following methods: O public boolean isOccupied (int floor, int row, int col) this method returns true if the location specified by the floor, row and column is already occupied by a vehicle. public void add (Vehicle v) this method will add the vehicle at the next empty slot. Slots are field row by row (from left to right) starting from the ground floor. public Vehicle remove (int floor, int row, int col, double rate) this method to removes the vehicle at the specified location and returns the parking fee. The fee is calculated by multiplying the rate by the duration (in minutes). Drivers will receive 5% discount per floor other than the ground floor. If the location is not occupied, the method returns zero. public double getTotalExpected Revenue(double[] rates, Date exitTime) this method calculates the total expected revenue if all cars exit the building at the given exitTime. The rates array will contain an element for every vehicle type (Sedan, SUV, Truck). public int getVehicle Count(String type, int floor) this method finds and returns the total number of cars for a given type in a given floor. O public double getRevenue (String type, int floor, double rate) this method finds and returns O O O O O the total revenue of a given car type in a given floor for a given rate. public boolean canOrganizeByType accommodate all cars of the same type in separate floors. this method should return true if it is possible to

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a CarParking class to model a multistory car parking building. This class should contain a 3-
dimensional array of type Vehicle. The third dimension of the array simply represents the number of
floors of the building while the first and second dimensions are the number of rows and columns in every
floor. By default, there are 3 floors, 7 rows and 7 columns in a building. However, the user should be able
to specify the maximum number of floors, rows and columns at the time of creating a CarParking object.
In addition to the constructors, this class should provide the following methods:
O public boolean isOccupied (int floor, int row, int col) this method returns true if the location
specified by the floor, row and column is already occupied by a vehicle.
o public void add (Vehicle v) this method will add the vehicle at the next empty slot. Slots are field
row by row (from left to right) starting from the ground floor.
public Vehicle remove (int floor, int row, int col, double rate) this method to removes the
vehicle at the specified location and returns the parking fee. The fee is calculated by multiplying
the rate by the duration (in minutes). Drivers will receive 5% discount per floor other than the
ground floor. If the location is not occupied, the method returns zero.
o public double getTotalExpected Revenue(double[] rates, Date exitTime) this method
calculates the total expected revenue if all cars exit the building at the given exitTime. The rates
array will contain an element for every vehicle type (Sedan, SUV, Truck).
o public int getVehicleCount(String type, int floor) this method finds and returns the total number
of cars for a given type in a given floor.
public double getRevenue (String type, int floor, double rate) this method finds and returns
the total revenue of a given car type in a given floor for a given rate.
public boolean canOrganizeByType ( this method should return true if it is possible to
accommodate all cars of the same type in separate floors.
O
O
O
Transcribed Image Text:Write a CarParking class to model a multistory car parking building. This class should contain a 3- dimensional array of type Vehicle. The third dimension of the array simply represents the number of floors of the building while the first and second dimensions are the number of rows and columns in every floor. By default, there are 3 floors, 7 rows and 7 columns in a building. However, the user should be able to specify the maximum number of floors, rows and columns at the time of creating a CarParking object. In addition to the constructors, this class should provide the following methods: O public boolean isOccupied (int floor, int row, int col) this method returns true if the location specified by the floor, row and column is already occupied by a vehicle. o public void add (Vehicle v) this method will add the vehicle at the next empty slot. Slots are field row by row (from left to right) starting from the ground floor. public Vehicle remove (int floor, int row, int col, double rate) this method to removes the vehicle at the specified location and returns the parking fee. The fee is calculated by multiplying the rate by the duration (in minutes). Drivers will receive 5% discount per floor other than the ground floor. If the location is not occupied, the method returns zero. o public double getTotalExpected Revenue(double[] rates, Date exitTime) this method calculates the total expected revenue if all cars exit the building at the given exitTime. The rates array will contain an element for every vehicle type (Sedan, SUV, Truck). o public int getVehicleCount(String type, int floor) this method finds and returns the total number of cars for a given type in a given floor. public double getRevenue (String type, int floor, double rate) this method finds and returns the total revenue of a given car type in a given floor for a given rate. public boolean canOrganizeByType ( this method should return true if it is possible to accommodate all cars of the same type in separate floors. O O O
Expert Solution
steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY