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

need in java, please label clearly which class is which and please don\' t copy.

ID: 3574921 • Letter: N

Question

need in java, please label clearly which class is which and please don' t copy.

Design a set of classes that, work together to simulate a police officer issuing a parking ticket. You should design the following, classes:

1. the ParkedCar class: this class should simulate a parked car. The class's responsibility 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: This class should a parking meter.. The class's only 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 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 that the car is illegally parked -To report the name and badge number of the police office issuing the ticket

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

Write a program that demonstrate these classes collaborate.

Explanation / Answer

Excecutable code :


public class PoliceOfficer {
   private String name;
   private int badgeNumber;
   private ParkedCar parkedcar;
   private ParkingMeter parkingmeter;
   private ParkingTicket parkingticket;
   public double fine = 0;

   public PoliceOfficer(String poname, int pobnumber, ParkedCar pcar, ParkingMeter pmeter) {
       name = poname;
       badgeNumber = pobnumber;

       parkedcar = new ParkedCar(pcar);

       parkingmeter = new ParkingMeter(pmeter);
   }

   public void set(String poname, int pobnumber) {
       name = poname;
       badgeNumber = pobnumber;
   }

   public PoliceOfficer(PoliceOfficer object2) {
       name = object2.name;
       badgeNumber = object2.badgeNumber;

   }

   public ParkedCar getParkedCar() {

       return new ParkedCar(parkedcar);
   }

   public ParkingMeter getParkingMeter() {

       return new ParkingMeter(parkingmeter);
   }

   public void inspectParkedCar() {

       if (parkedcar.minutes > parkingmeter.minutesPurchased)

           if (parkedcar.minutes - parkingmeter.minutesPurchased <= 60)
               fine = 25;
           else
               fine = 25 + (10 * ((parkedcar.minutes - parkingmeter.minutesPurchased) / 60));

       parkingticket = new ParkingTicket(fine, parkedcar, parkingmeter);
   }
}


public class ParkingTicket {
   private double fine;
   private ParkedCar parkedcar;
   private ParkingMeter parkingmeter;
   private PoliceOfficer policeofficer;

   public ParkingTicket(double fine, ParkedCar pcar, ParkingMeter pmeter) {

       parkedcar = new ParkedCar(pcar);

       parkingmeter = new ParkingMeter(pmeter);

       this.fine = fine;
   }

   public String toString() {

       String str = "Illegally parked car info: " + parkedcar + " Parking meter info:" + parkingmeter
               + " Amount of the fine...: " + fine;

       return str;
   }
}


public class ParkingMeter {
   public int minutesPurchased;

   public ParkingMeter(int pmmpurchased) {
       minutesPurchased = pmmpurchased;
   }

   public void set(int pmmpurchased) {
       minutesPurchased = pmmpurchased;
   }

   public ParkingMeter(ParkingMeter object2) {
       minutesPurchased = object2.minutesPurchased;
   }

   public int getMintuesPurchased() {
       return minutesPurchased;
   }
}

public class ParkedCar {
   private String make;
   private String model;
   private String color;
   private String licenseNumber;
   public int minutes;

   public ParkedCar(String pcmake, String pcmodel, String pccolor, String pclnumber, int pcminutes) {
       make = pcmake;
       model = pcmodel;
       color = pccolor;
       licenseNumber = pclnumber;
       minutes = pcminutes;
   }

   public void set(String pcmake, String pcmodel, String pccolor, String pclnumber, int pcminutes) {
       make = pcmake;
       model = pcmodel;
       color = pccolor;
       licenseNumber = pclnumber;
       minutes = pcminutes;
   }

   public ParkedCar(ParkedCar object2) {
       make = object2.make;
       model = object2.model;
       color = object2.color;
       licenseNumber = object2.licenseNumber;
       minutes = object2.minutes;
   }

   public String toString() {

       String str = "Parked car's make.....................: " + make + " Parked car's model..................: "
               + model + " Parked car's color..................: " + color
               + " Parked car's license plate number...: " + licenseNumber
               + " Minutes that the car has been parked: " + minutes;

       return str;
   }

}

public class Demo {

   public static void main(String[] args) {
       ParkedCar myParkedCar = new ParkedCar("Chevrolet", "Lumina APV", "White", "556 TNT", 48);

       ParkingMeter myParkingMeter = new ParkingMeter(48);

       PoliceOfficer myPoliceOfficer = new PoliceOfficer("John Doe", 1337, myParkedCar, myParkingMeter);

       myPoliceOfficer.inspectParkedCar();

       ParkingTicket myParkingTicket = new ParkingTicket(myPoliceOfficer.fine, myParkedCar, myParkingMeter);
       myParkingTicket.toString();

       myParkedCar.toString();

   }
}