Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

you will design a set of classes that work together to simulate a police officer

ID: 3641108 • Letter: Y

Question

you will design a set of classes that work together to simulate a police officer issuing a parking ticket. The classes you should design are:

• The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are:
- To know the car’s make, model, color, license number, and the number of minutes that the car has been parked

• The ParkingMeter Class: This class should simulate a parking meter. The class’s only responsibility is:
- To know the number of minutes of parking time that has been purchased.

• The ParkingTicket Class: This class should simulate a parking ticket. The class’s responsibilities are:
- 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 illegally parked, plus $10 for every additional hour or part of an hour or part of an hour that the car is illegally parked
- To report the name and badge number of the police officer issuing the ticket

• The PoliceOfficer Class: This class should simulate a police officer inspecting parked cars. The class’s responsibilities are:
- To know the police officer’s name and badge number
- To examine a ParkedCar object and a ParkingMeter object, and determine whether the car’s time has expired
- To issue a parking ticket (generate a ParkingTicket object) if the car’s time has expired

Write a program that demonstrates how these classes collaborate.
(please help me and please put documentation if you don't mind)

Explanation / Answer

public class ParkedCar { //------------------------------------------- //Attributes //------------------------------------------- /** * Represents the make of the car */ private String make; /** * Represents the model of the car */ private String model; /** * Represents the color of the car */ private String color; /** * Represents the licenseNumber of the car */ private String licenseNumber; /** * Represents the minutes parked of the car */ private int minutesParked; //------------------------------------------- //Constructors //------------------------------------------- /** * Create a new Parked Car with attributes = null */ public ParkedCar() { make = null; model = null; color = null; licenseNumber = null; minutesParked = -1; } /** * Create a new parked car with the parameters of input * @param pModel the model of the car * @param pColor the color of the car * @param pLicenseNumber the license of the car * @param pMinutesParked the minutes that the car was parked */ public ParkedCar(String pModel, String pColor, String pLicenseNumber, int pMinutesParked) { model = pModel; color = pColor; licenseNumber = pLicenseNumber; minutesParked = pMinutesParked; } //------------------------------------------- //Methods //------------------------------------------- /** * Return the make of the car; * @return make The make of the car */ public String getMake() { return make; } /** * Returns the model of the car * @return model The model of the car */ public String getModel() { return model; } /** * Returns the color of the car * @return color The color of the car */ public String getColor() { return color; } /** * Returns the license number of the car * @return licenseNumber The licenseNumber of the car */ public String getLicenseNumber() { return licenseNumber; } /** * Return the minutes that the car was parked * @return the minutes thet the car was parked */ public int getMinutesParked() { return minutesParked; } } --------------------------------------------------------------------------------------------------- public class ParkingMeter { //------------------------------------------- //Attributes //------------------------------------------- /** * Represents the parking time that has been purchased */ private int purchasedTime; //------------------------------------------- //Constructors //------------------------------------------- /** * Creates a new ParkinMeter with purchased time = -1 */ public ParkingMeter() { purchasedTime = -1; } /** * Creates a new ParkingMeter with * @param pPurchasedTime the purchased time */ public ParkingMeter(int pPurchasedTime) { purchasedTime = pPurchasedTime; } //------------------------------------------- //Methods //------------------------------------------- /** * Returns the purchased time * @return purchasedTime The time that has been purchased */ public int getPurchasedTime() { return purchasedTime; } } -------------------------------------------------------------------------------------------- public class ParkingTicket { //------------------------------------------- //Constants //------------------------------------------- /** * Is the fine for the first hour */ public final static double FIRST_HOUR = 25; /** * is the fine for the additional hour */ public final static double ADITIONAL_HOUR = 10; //------------------------------------------- //Attributes //------------------------------------------- /** * Represents the make of the ticket */ private String make; /** * Represents the model of the ticket */ private String model; /** * Represents the color of the ticket */ private String color; /** * Represents the licenseNumber of the ticket */ private String licenseNumber; /** * Represents the amount of fine */ private double amountOfFine; /** * Represents the name of the police officer that issued the ticket */ private String officerName; /** * Represents badge number of the police officer that issued the ticket */ private String badgeNumber; //-------------------------------------------- //Constructors //-------------------------------------------- /** * Create a new Ticket with attributes = null */ public ParkingTicket() { make= null; model = null; color = null; licenseNumber =null; officerName = null; badgeNumber = null; } /** * Crates the Parking ticket with the given parameters * @param pMake the make of the car * @param pModel the model of the car * @param pColor the color of the car * @param pLicenseNumber the licenseNumber of the car * @param pOfficerName the name of the officer that issued the ticket * @param pBadgeNumber the badge number of the officer that issued the ticket */ public ParkingTicket(String pMake, String pModel, String pColor, String pLicenseNumber, String pOfficerName, String pBadgeNumber) { make = pMake; model = pModel; color = pColor; licenseNumber = pLicenseNumber; officerName = pOfficerName; badgeNumber = pBadgeNumber; } //-------------------------------------------- //Methods //-------------------------------------------- /** * Sets the fine of the ticket * @param minutesParked the minutes that the car was parked * @param minutesPurshased the minutes that has been purchased */ public void setFine(int minutesParked, int minutesPurshased) { if(minutesParked - minutesPurshased > 0 && minutesParked - minutesPurshased pParkingMeter.getPurchasedTime()) { return true; } else return false; } public void issuedParkincgTicket(ParkedCar pParkedCar) { ParkingTicket newTicket = new ParkingTicket(pParkedCar.getMake(), pParkedCar.getModel(), pParkedCar.getColor(), pParkedCar.getLicenseNumber(), name, badgeNumber); tickets.add(newTicket); } }