Question: Java language fix problem Directions: currently the code dosent output what the instructions ask for. Change the output to display of everything the instructions ask

Java language fix problem

Directions:

currently the code dosent output what the instructions ask for. Change the output to display of everything the instructions ask for.

Example

Enter the name of police officer :Charlee Enter the badge number :26 Enter the car's make:Alpha Enter the car's model:B35 Enter the car's color:Red Enter the car's licence number:543/B Enter the no. of minutes car parked:50 Enter the no of minutes puchased for parking:30

Details of illegally parked car: Car's make :Alpha Car's model :B35 Car's color :Red Car's licence number :543/B Fine is : $45 Name of officier :Charlee Badge number :26

//*

8. Parking Ticket Simulator 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:

The ParkedCar Class: This class should simulate a parked car. The classs responsibili- ties are as follows:

To know the cars 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 classs only responsibility is as follows: To know the number of minutes of parking time that has been purchased.

The ParkingTicket Class: This class should simulate a parking ticket. The classs 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 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 officer issuing the ticket The PoliceOfficer Class: This class should simulate a police officer inspecting parked cars. The classs responsibilities are as follows: To know the police officers name and badge number To examine a ParkedCar object and a ParkingMeter object, and determine whether the cars time has expired To issue a parking ticket (generate a ParkingTicket object) if the cars time has expired Write a program that demonstrates how these classes collaborate.

class PoliceOfficer {

private String name;

private String badgeNumber;

public PoliceOfficer(String name, String badgeNumber) {

super();

this.name = name;

this.badgeNumber = badgeNumber;

}

public ParkingTicket patrol(ParkedCar car, ParkingMeter meter) {

ParkingTicket ticket = null;

// Calculate the total number of minutes parked over minutes

// purchased

int illegalMinutes = car.getMinutesParked()

- meter.getMinutesPurchased();

// if illegalMinutes, give ticket

if (illegalMinutes > 0) {

// Yes, it is illegally parked.

ticket = new ParkingTicket(car, this, illegalMinutes);

}

return ticket;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getBadgeNumber() {

return badgeNumber;

}

public void setBadgeNumber(String badgeNumber) {

this.badgeNumber = badgeNumber;

}

}

class ParkingTicketSimulator {

public static void main(String[] args) {

// A green car was parked for 125 minutes

//ParkingTicketSimulator parkingTicketSimulator = new ParkingTicketSimulator();

ParkedCar car = new ParkedCar("BMW", "2018",

"Red", "BBB333", 125);

// 60 minutes of time was purchased

ParkingMeter meter = new ParkingMeter(60);

// Officer Jack was on duty

PoliceOfficer officer = new PoliceOfficer(

"Jack", "8888");

ParkingTicket ticket = officer.patrol(car, meter);

// Did the officer issue a ticket?

if (ticket != null) {

System.out.println(ticket);

} else {

System.out.println("No crimes committed!");

}

}

}

class ParkingTicket {

private ParkedCar car;

private PoliceOfficer officer;

private double fine;

private int minutes;

public final double BASE_FINE = 25.0;

public final double HOURLY_FINE = 10.0;

public ParkingTicket(ParkedCar car, PoliceOfficer officer, int minutes) {

super();

this.car = car;

this.officer = officer;

this.minutes = minutes;

calculateFine();

}

private void calculateFine() {

double hours = minutes / 60.0;

int hoursAsInt = (int) hours;

if ((hours - hoursAsInt) > 0) {

hoursAsInt++;

}

// Assign the base fine.

fine = BASE_FINE;

// Add the additional hourly fines.

fine += (hoursAsInt * HOURLY_FINE);

}

public ParkedCar getCar() {

return car;

}

public void setCar(ParkedCar car) {

this.car = car;

}

public PoliceOfficer getOfficer() {

return officer;

}

public void setOfficer(PoliceOfficer officer) {

this.officer = officer;

}

public double getFine() {

return fine;

}

public void setFine(double fine) {

this.fine = fine;

}

public int getMinutes() {

return minutes;

}

public void setMinutes(int minutes) {

this.minutes = minutes;

}

@Override

public String toString() {

return "ParkingTicket [car=" + car + ", officer=" + officer

+ ", fine=" + fine + ", minutes=" + minutes

+ ", BASE_FINE=" + BASE_FINE + ", HOURLY_FINE="

+ HOURLY_FINE + "]";

}

}

class ParkingMeter {

private int minutesPurchased;

public ParkingMeter(int minutesPurchased) {

super();

this.minutesPurchased = minutesPurchased;

}

public int getMinutesPurchased() {

return minutesPurchased;

}

public void setMinutesPurchased(int minutesPurchased) {

this.minutesPurchased = minutesPurchased;

}

}

class ParkedCar {

private String make;

private String model;

private String color;

private String licenseNumber;

private int minutesParked;

public ParkedCar(String make, String model, String color,

String licenseNumber, int minutesParked) {

super();

this.make = make;

this.model = model;

this.color = color;

this.licenseNumber = licenseNumber;

this.minutesParked = minutesParked;

}

public String getMake() {

return make;

}

public void setMake(String make) {

this.make = make;

}

public String getModel() {

return model;

}

public void setModel(String model) {

this.model = model;

}

public String getColor() {

return color;

}

public void setColor(String color) {

this.color = color;

}

public String getLicenseNumber() {

return licenseNumber;

}

public void setLicenseNumber(String licenseNumber) {

this.licenseNumber = licenseNumber;

}

public int getMinutesParked() {

return minutesParked;

}

public void setMinutesParked(int minutesParked) {

this.minutesParked = minutesParked;

}

}

OutPut:**

ParkingTicket [car=ParkedCar@15db9742, officer=PoliceOfficer@6d06d69c, fine=45.0, minutes=65, BASE_FINE=25.0, HOURLY_FINE=10.0] Press any key to continue . . .

**

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!