Question

Please help me with this exercises in JAVA, Thank you ===================== Parking Ticket Simulator Assignment =====================...

Please help me with this exercises in JAVA, Thank you

=====================

Parking Ticket Simulator Assignment

=====================

For this assignment you will create a set of classes from scratch (no provided class files for this assignment) that work together to simulate a police officer issuing a parking ticket. You should design the following classes / functionality within them:

=====================
ParkedCar.java:

=====================
This class should simulate a parked car. The class's responsibilities are as follows:
- To store the car's make, model, color, license number, and the number of minutes that the car has been parked.

=====================
ParkingMeter.java:

=====================

This class should simulate a parking meter. The class's only responsibility is as follows:
- To know the number of minutes of parking time that has been purchased.

=====================
PoliceOfficer.java:

=====================

This class should simulate a police officer inspecting parked
cars. The class's responsibilities 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 the car's time has expired
- To issue a parking ticket (generate a ParkingTicket object) if the car's time has expired

=====================
ParkingTicket.java:

=====================

This class should simulate a parking ticket - this class will contain a main() method that will set up a scenario to show a ParkingTicket being issued to a ParkedCar.

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 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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class ParkedCar
{ String make, model, color, license;
int minutes;
public ParkedCar(String cMake, String cModel, String cColor, String cLicense, int cMinutes)
{ make = cMake;
model = cModel;
color = cColor;
license = cLicense
minutes = cMinutes;
}
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 getColour()
       {
return color;
}

public void setColour(String color)
       {
       this.color = color;
       }

public String getLicenseNumber()
      
       {
return license;
}

public void setLicenseNumber(String license)
       {
this.license = license;
}

public int getMinutesParked()
       {
return minutes;
}

public void setMinutesParked(int minutes)
       {
this.minutes = minutes;
}

}

public class ParkingMeter
{

private int purchasedMinutes;

public ParkingMeter()
       {

}

public ParkingMeter(int purchasedMins)
       {
purchasedMinutes = purchasedMins;
}

public int getMinutesPurchased()
       {
return purchasedMinutes;
}

public void setMinutesPurchased(int purchasedMinutes)
       {
this.purchasedMinutes = purchasedMinutes;
}

public String toString()
       {
String toString = "Minutes that was purchased: " + purchasedMinutes;
return toString;
}
       }

public class PoliceOfficer
{

String name, badge;

public PoliceOfficer()
       {

}

public PoliceOfficer(String name, String badge)
       {
this.name = name;
this.badge = badge;
}

public String getName()
       {
return name;
}

public void setName(String name)
       {
this.name = name;
}

public String getBadge()
       {
return badge;
}

public void setBadge(String badge)
       {
this.badge = badge;
}

public ParkingTicket()
{

}

public ParkingTicket(ParkedCar car, PoliceOfficer cop)
       {
this.car = car;
this.cop = cop;
this.parkingMeter = parkingMeter;
}

public ParkedCar getCar()
       {
return car;
}

public void setCar(ParkedCar car)
       {
this.car = car;
}

public PoliceOfficer getCop()
       {
return cop;
}

public void setCop(PoliceOfficer cop)
       {
this.cop = cop;
}

public ParkingMeter getParkingMeter()
       {
return parkingMeter;
}

public void setParkingMeter(ParkingMeter parkingMeter)
       {
this.parkingMeter = parkingMeter;
}

@Override
public String toString()
       {
String toString = "License Number: " + car.getLicenseNumber() + "\nMake: " + car.getMake()
+ "\nModel: " + car.getModel() + "\nColour: " + car.getColour()
+ "\nFine: $" +String.format("%.2f",this.fine) + "\nOfficer: " + cop.getName() + "\nBadge: " + cop.getBadge();
return toString;
}}


public ParkingTicket writeTicket(ParkedCar car, ParkingMeter minutes) { public boolean checkIllegallyParked(ParkedCar car, ParkingMeter minutes) {
//int mins = car.getMinutesParked() - minutes.getMinutesPurchased();
if (car.getMinutesParked() > minutes.getMinutesPurchased()) {
return true;
} else {
return false;
}
}

ParkingTicket ticket = new ParkingTicket(car, this);
int remainingMinutes = car.getMinutesParked() - minutes.getMinutesPurchased();
  
if (checkIllegallyParked(car, minutes) == true)
           {
if (remainingMinutes <= 60)
               {
          
ticket.fine = 25;
} else

{
ticket.fine = 25 + (10 * (remainingMinutes / 60));
}   
return ticket;
} }


  

Add a comment
Know the answer?
Add Answer to:
Please help me with this exercises in JAVA, Thank you ===================== Parking Ticket Simulator Assignment =====================...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT