160k views
0 votes
You may have noticed that Humber has a parking system to inform drivers if parking spots are available and how many parking spots are available. Lets build a variation of Humber's parking system. This parking system will have 3 different sizes of parking spaces, big, medium, and small. Of course, we will also have cars of different sizes. Create a ParkingSystem class and a Car class. The ParkingSystem will know how many spots of big, medium, and small parking spots there are. Create a constructor for ParkingSystem that defines the number of big, medium, and small spots. The big spots will fit cars under 500cm length and 200cm width, medium spots will fit cars under 450cm and 180cm width, and small spots will fit cars under 400cm and 170cm width. The Car class will have a width and length. The Car will have a constructor for width and length. Create a method in ParkingSystem called addCar. If the ParkingSystem is able to add the car, return true. Otherwise, return false. Create getters for number of spots remaining; getBigSpots, getMediumSpots, getSmallSpots. Each should return how many spots are remaining. The ParkingSystem should try to fit as many cars as possible.

User Ghobs
by
8.1k points

1 Answer

2 votes

Final answer:

In this Computers and Technology question, we are building a variation of a parking system using a ParkingSystem class and a Car class. The ParkingSystem will have information about the number of big, medium, and small parking spots, and the Car class will have information about the width and length of the car. The system will be able to add cars based on their dimensions and provide information about the remaining spots.

Step-by-step explanation:

The subject of this question is Computers and Technology. In this question, we are tasked with building a variation of Humber's parking system using a ParkingSystem class and a Car class. The ParkingSystem class will have information about the number of big, medium, and small parking spots, as well as a method to add a car to the system. The Car class will have information about the width and length of the car.

The ParkingSystem constructor will define the number of big, medium, and small spots, with specific size requirements for each spot. The addCar method in the ParkingSystem will check if there is an available spot that can accommodate the given car's dimensions and return true if the car can be added to the system. If not, it will return false. There are also getters in the ParkingSystem class to retrieve the number of remaining spots for each size category.

By implementing this ParkingSystem, we can efficiently manage parking spots for cars of different sizes and optimize the usage of available spots.

User Pathdependent
by
7.6k points