Design a set of classes that work together to simulate a police issuing a parkin
ID: 3621476 • Letter: D
Question
Design a set of classes that work together to simulate a police issuing a parking ticket. Design the following classes.1. The ParkedCar Class: This should simulate a parked car. The class's responsibilities are as follows:
- To know the car's make, model, color, license number, and the number of minutes that the car has been parked.
2. The ParkingMeter Class: It should simulate a parking meter. The class's oly responsibility is as follows
- To know the number of minutes of parking time that has been purchased.
3. The ParkingTicket Class: This class should simulate a parking ticket. The class's responsibilities are as follows
- To report the make , model, color and license number of the illegally parked car
- to report the amount of the fine, which is $ 25 for the first hour or part of an hour that the car is illegaly parked, plus $10 for every additional hour or part of an hour tht the care is illegaly parked
-To report the name and badge number of the police officer issuing the ticket
4. The PoliceOfficer Class: This class should simulate the officer inspecting parked cars. the class's responsibilities are as follows:
- to know the police officers name and badge number
-To examine a ParkedCar Object and a ParkingMeter object, and deeterming whether the cars time has expired.
-To issue a parking ticket(generate a ParkingTicket object) if the car's time has expried
Write a program that demonstrates how these classes collaborate.
Explanation / Answer
The ParkedCar Class: public class ParkedCar { private String make; private String model; private String color; private String licenseNumber; private int minutes; public ParkedCar(String mke, String modl, String colr, String lsn, int m) { make = mke; model = modl; color = colr; licenseNumber = lsn; minutes = m; } public ParkedCar(parkedCar p) { make = p.make; model = p.model; color = p.color; licenseNumber = p.licenseNumber; minutes = p.minutes; } public void set(String mke, String modl, String colr, String lsn, int m) { make = mke; model = modl; color = colr; licenseNumber = lsn; minutesParked = m; } public String getmake() { return make; } public String getmodel() { return model; } public String getcolor() { return color; } public String getlicenseNumber() { return licenseNumber; } public int getminutes() { return minutes; } public String toString() { String str = "Make: " + make + " Model: " + model + " Color: " + color + " License Number: " + licenseNumber + " Minutes Parked: " + minutes+ " "; return str; } } ParkingMeter Class: public class parkingMeter { private int num_minutes_Pur; public parkingMeter(int mp) { num_minutes_Pur = min; } public void set(int min) { num_minutes_Pur = min; } public double getnumminpur() { return num_minutes_Pur; } public String toString() { String str = "The number of minutes of parking time purchased: " + num_minutes_Pur; return str; } } I hope this will helps to You !
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.