parking Ticket simulator For this assignment you will design a set of classes that work together...

70.2K

Verified Solution

Question

Programming

parking Ticket simulator For this assignment you will design aset of classes that work together to simulate a police officerissuing a parking ticket. You should design the followingclasses:

• The ParkedCar Class: This class should simulate a parked car.The class’s responsibili-ties are as follows: – To know the car’smake, model, color, license number, and the number of minutes thatthe car has been parked.

• The ParkingMeter Class: This class should simulate a parkingmeter. The class’s only responsibility is as follows: – To know thenumber of minutes of parking time that has been purchased.

• The ParkingTicket Class: This class should simulate a parkingticket. The class’s responsibilities are as follows:

– To report the make, model, color, and license number of theillegally parked car

– To report the amount of the fine, which is $25 for the firsthour or part of an hour that the car is illegally parked, plus $10for every additional hour or part of an hour that the car isillegally parked

– To report the name and badge number of the police officerissuing the ticket

• The PoliceOfficer Class: This class should simulate a policeofficer inspecting parked cars. The class’s responsibilities are asfollows:

– To know the police officer’s name and badge number

– To examine a ParkedCar object and a ParkingMeter object, anddetermine whether the car’s time has expired

– To issue a parking ticket (generate a ParkingTicket object) ifthe car’s time has expired Write a program that demonstrates howthese classes collaborate.

Manual grading requirements:

No data must be collected from the user from inside the classconstructor or any other methods. Data must be collected outsidethe class(perhaps in the main) and can be passed into the objectthrough constructors. This applies to Car, ParkingTicket,PoliceOfficer, ParkingMeter and all other classes.

For any constructor, pass only information that is needed toinitialize the objects of that class. For example, when you createpolice officer object, pass only police office information to buildthe object, not car, or parking meter information.

Mimir Requirements

File name to submit in mimir must be:ParkingCarSimulator.java

Test Case1:

Enter the officer's name
John
Enter officer's badge number
1234
Enter the car's make
Toyota
Enter the car's model
Carolla
Enter the car's color
Purple
Enter the car's liscense number
34RJXYZ
Enter Minutes on car
20
Enter the number of minutes purchased on the meter
15
Car parking time has expired.

Ticket data:

Make: Toyota

Model: Carolla

Color: Purple

Liscense Number: 34RJXYZ

Officer Name: John

Badge Number: 1234

Fine: 25.0

Test Case 2( No Ticket Generated)

Enter the officer's name
Susan
Enter officer's badge number
455454
Enter the car's make
BMW
Enter the car's model
E300
Enter the car's color
White
Enter the car's liscense number
CA3433
Enter Minutes on car
45
Enter the number of minutes purchased on the meter
60
The car parking minutes are valid

Test Case 3( Validate input data)

Enter the officer's name
Adam
Enter officer's badge number
34343
Enter the car's make
Ford
Enter the car's model
Model5
Enter the car's color
Green
Enter the car's liscense number
CA55443
Enter Minutes on car
-12
Invalid Entry. Please try again.
20
Enter the number of minutes purchased on the meter
0
Invalid Entry. Please try again.
-20
Invalid Entry. Please try again.
15
Car parking time has expired.

Ticket data:

Make: Ford

Model: Model5

Color: Green

Liscense Number: CA55443

Officer Name: Adam

Badge Number: 34343

Fine: 25.0

ACTIONS

This is what I have so far

ParkedCar.javafile------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class ParkedCar {

private String make = newString();

private String model = newString();

private String color = newString();

private String licenseNum =new String();

private int parkedMin;

public ParkedCar(String m1, String m2, Stringc, String l, int p)

{

make = m1;

model = m2;

color = c;

licenseNum = l;

parkedMin = p;

}

//Create Accessor methods to return Car info

public String getMake() {

return make;

}

public String getModel() {

return model;

}

public String getColor() {

return color;

}

public String getLicense() {

return licenseNum;

}

public int getParkedMinutes(){

return parkedMin;

}

//Create Mutator methods

public void setMake(String m1){

make = m1;

}

public void setModel(Stringm2) {

model = m2;

}

public void setColor(String c){

color = c;

}

public void setLicense(Stringl) {

licenseNum = l;

}

public voidsetParkedMinutes(int p) {

parkedMin = p;

}

}

ParkingTicket.javaFile------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class ParkingTicket{

private ParkedCar Car;

private PoliceOfficer officer;

private double fineAmount;

private int minutes;

//Constant

public finaldouble firstHourFine = 25.0;

public finalint additionalHourFine = 10;

//Constructor

public ParkingTicket(ParkedCar Car,PoliceOfficer officer) {

}

}

ParkingMeter.javafile------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class ParkingMeter{

private int purchasedMin;

public ParkingMeter(int p)

{

purchasedMin = p;

}

//Create Accessor methods

public int getPurchasedMin(){

return purchasedMin;

}

//Create Mutator Methods

public voidsetPurchasedMin(int p) {

purchasedMin = p;

}

}

PoliceOfficer.java File------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class PoliceOfficer{

private String officerName;

private int badgeNum;

public PoliceOfficer(String name,int num) {

officerName = name;

badgeNum = num;

}

public String getName() {

return officerName;

}

public int getBadge() {

return badgeNum;

}

public void setName(Stringname) {

officerName = name;

}

public voidsetBadge(int num) {

badgeNum = num;

}

}

ParkingSimulatorTest.javafile------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

import java.util.Scanner;

public classParkingSimulatorTest {

public staticvoid main(String[] args) {

String officerName, carMake, carModel, carColor,carLicenseNum;

int minPurchased = 0, parkedMin, badgeNum;

//Create a Scanner object to accept user input

Scanner keyboard = newScanner(System.in);

System.out.println(\"Enter theofficer's name\");

officerName = keyboard.nextLine();

System.out.println(\"Enter officer'sbadge number\");

badgeNum = keyboard.nextInt();

System.out.println(\"Enter the car'smake\");

carMake = keyboard.next();

System.out.println(\"Enter the car'smodel\");

carModel = keyboard.nextLine();

System.out.println(\"Enter the car'scolor\");

carColor = keyboard.nextLine();

System.out.println(\"Enter the car'sliscense number\");

carLicenseNum = keyboard.nextLine();

System.out.println(\"Enter Minutes oncar\");

parkedMin = keyboard.nextInt();

System.out.println(\"Enter the numberof minutes purchased on the meter\");

//Create Police Officer Object

PoliceOfficer policeOfficer = newPoliceOfficer(officerName, badgeNum);

//Create car Object

ParkedCar parkedCar = new ParkedCar(carMake,carModel, carColor, carLicenseNum, parkedMin);

//Create a parking meter object

ParkingMeter meter = newParkingMeter(minPurchased);

}

Please Help I need to know If I am on the right track and whatother things do I need.

Answer & Explanation Solved by verified expert
4.1 Ratings (532 Votes)
import javaioimport javautilScanner ParkedCar class class ParkedCar variable declarations private String carMake private String carModel private String carColor private String carLicenseNo private int minsParked Constructor public ParkedCarString cmak String cmodString ccol String cLno int mins thiscarMake cmak thiscarModel cmodthiscarColor ccol thiscarLicenseNo cLno thisminsParked mins Constructor public ParkedCarParkedCar car1 thiscarMake car1carMake thiscarModel car1carModel thiscarColor car1carColor thiscarLicenseNo car1carLicenseNo thisminsParked car1minsParked set method for Make public void setCarMakeString m thiscarMake m set method for Model public void setCarModelString m thiscarModel m set    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students