Question: For this assignment, you will design a set of classes that work together to simulate a police officer issuing a parking ticket. You should design

For this assignment, you will design a set of classes that work together to simulate a police officer issuing a parking ticket. You should design the following classes: ParkedCar Class: This class simulates a parked car and should know the cars make, model, color, license number, and the number of minutes that the car has been parked. ParkingMeter Class: This class simulates a parking meter and should know the number of minutes of parking time that has been purchased. PoliceOfficer Class: This class simulates a police officer and should know the police officers name and badge number. This class should examine a ParkedCar and ParkingMeter object to determine whether the cars time has expired. This class should generate a ParkingTicket object if the cars time has expired. ParkingTicket Class: This class simulates a parking ticket and should report the make, model, color, and license number of the illegally parked car. This class should report the amount of the fine, which is $25 for the first hour and an additional $10 for every additional hour. This class should report the name and badge number of the police officer issuing the parking ticket. Write a program called ParkingTicketDemo that demonstrates how these classes will collaborate.

Bellow is what I came up with for this assignment, there are a hand full of errors in it that wont let me run the program. I need help fixing it. I also attached the errors that netbeans gave.

package parkingticketdemo;

public class ParkingTicketDemo {

public static void main(String[] args) { PoliceOfficer joe = new PoliceOfficer("Joe Dirt", "HH666"); ParkedCar accord = new ParkedCar("Honda", "Accord 2007", "black", "ABC123", 182); ParkingMeter meter = new ParkingMeter(30); joe.examineParkedCar(accord, meter); } }

ParkedCar.java

public class ParkedCar { private String make, model, color, licenseNo; private int minutesParked; /** * Constructor for ParkedCar. Sets the car's make, model, color, license number, and minutes parked * from parameters given. * * @param make The make of the car * @param model The model of the car * @param color The color of the car * @param licenseNo The car's license number * @param minutesParked The minutes the car has been parked */ public ParkedCar(String make, String model, String color, String licenseNo, int minutesParked) { super(); this.make = make; this.model = model; this.color = color; this.licenseNo = licenseNo; this.minutesParked = minutesParked; } public String getColor() { return color; } public String getLicenseNumber() { return licenseNo; } public String getMake() { return make; } public int getMinutesParked() { return minutesParked; } public String getModel() { return model; } public void setColor(String color) { this.color = color; } public void setLicenseNumber(String licenseNumber) { this.licenseNo = licenseNo; } public void setMake(String make) { this.make = make; } public void setMinutesParked(int minutesParked) { this.minutesParked = minutesParked; } public void setModel(String model) { this.model = model; } }

ParkingMeter.java

public class ParkingMeter { int parkingTimePurchased; /** * Sets the meter's amount of parking time purchased to the amount given. * * @param parkingTimePurchased Amount of parking time purchased */ ParkingMeter(int parkingTimePurchased) { setParkingTimePurchased(parkingTimePurchased); } public int getParkingTimePurchased() { return parkingTimePurchased; } public void setParkingTimePurchased(int parkingTimePurchased) { this.parkingTimePurchased = parkingTimePurchased; } }

ParkingTicket.java

public class ParkingTicket { ParkedCar parkedCar; ParkingMeter parkingMeter; PoliceOfficer policeOfficer; /** * Sets the police officer, the parked car, and the parking meter according to the parameters. * * @param policeOfficer The police officer who issued the ticket * @param parkedCar The illegally parked car * @param parkingMeter The parking meter of the illegally parked car */ ParkingTicket(PoliceOfficer policeOfficer, ParkedCar parkedCar, ParkingMeter parkingMeter) { this.policeOfficer = policeOfficer; this.parkedCar = parkedCar; this.parkingMeter = parkingMeter; } public String getColor() { return parkedCar.getColor(); } public Double getFine() { int illegalMinutes = parkedCar.getMinutesParked() - parkingMeter.getParkingTimePurchased(); double fine = 0; /* * Adds the appropriate amount to the fine and then subtracts * the number of minutes fined from illegalMinutes until * illegalMinutes is equal to, or less than zero. */ if(illegalMinutes >= 60) { fine += 25.00; illegalMinutes -= 60; } while(illegalMinutes > 0) { if(illegalMinutes >= 60) { fine += 10.00; illegalMinutes -= 60; } else { fine += 10.00; illegalMinutes -= illegalMinutes; } } return fine; } public String getLicenseNo() { return parkedCar.getLicenseNumber(); } public String getMake() { return parkedCar.getMake(); } public String getModel() { return parkedCar.getModel(); } public String getOfficerBadgeNumber() { return policeOfficer.getBadgeNumber(); } public String getOfficerName() { return policeOfficer.getName(); } }

PoliceOfficer.java

public class PoliceOfficer { private String name, badgeNumber; PoliceOfficer(String name, String badgeNumber) { this.name = name; this.badgeNumber = badgeNumber; } /** * Checks if a parked car's time parked has exceeded the time * purchased on the parking meter. * * If the car is parked legally, * "Car's name is legally parked." is printed. * * If the car is parked * illegally, "Car's name is illegally parked. Ticket issued." is * printed and a new ParkingTicket object is created. The parking ticket's * information is then printed. */ public void examineParkedCar(ParkedCar parkedCar, ParkingMeter parkingMeter) { if(parkingMeter.getParkingTimePurchased() < parkedCar.getMinutesParked()) { ParkingTicket parkingTicket = new ParkingTicket(this, parkedCar, parkingMeter); System.out.println(parkedCar.getModel() + " is illegally parked. Ticket issued."); // Prints parking ticket's information System.out.println(" Parking ticket:"); System.out.println("Issuing officer's name: " + parkingTicket.getOfficerName()); System.out.println("Issuing officer's badge number: " + parkingTicket.getOfficerBadgeNumber()); System.out.println("Fine: $" + parkingTicket.getFine()); } else { System.out.println(parkedCar.getModel() + " is legally parked."); } } public String getBadgeNumber() { return badgeNumber; } public String getName() { return name; } }

Netbeans:C:\Users\Bene\Documents\NetBeansProjects\ParkingTicketDemo\src\parkingticketdemo\ParkingTicketDemo.java:25: error: class, interface, or enum expected ParkedCar.java C:\Users\Bene\Documents\NetBeansProjects\ParkingTicketDemo\src\parkingticketdemo\ParkingTicketDemo.java:93: error: class, interface, or enum expected ParkingMeter.java C:\Users\Bene\Documents\NetBeansProjects\ParkingTicketDemo\src\parkingticketdemo\ParkingTicketDemo.java:118: error: class, interface, or enum expected ParkingTicket.java 3 errors C:\Users\Bene\Documents\NetBeansProjects\ParkingTicketDemo bproject\build-impl.xml:955: The following error occurred while executing this line: C:\Users\Bene\Documents\NetBeansProjects\ParkingTicketDemo bproject\build-impl.xml:295: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 0 seconds)

I tried it again as suggested, but it still doesn't work in netbeans. I don't know why its not working.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!