Question

I need help with this java project and please follow the instruction below. thank Class Project...

I need help with this java project and please follow the instruction below. thank

Class Project - Parking Ticket simulator

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

•           The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are as follows:

– To know the car’s 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 class’s 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 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

•           The PoliceOfficer Class: 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 .

Create a database Called ParkTickets. Create a table for ParkedCar, ParkingTicket, ParkingMeter. The parking meter should be assigned a unique id, and PoliceOfficer. The fields for the tables should be the same ones as created for each object in the classes.

Create an input screen to enter data for the ParkedCar into the ParkedCar table

Create an input screen to enter ParkingTicket data into this table. When entering this data, validate the Car against the ParkedCar table. In other words, if ParkedCar record does not exist, issue a valid error message.

Create an Input screen to input records for each entity in your database.

Write a program that demonstrates how these classes and databases collaborate

I will need each member name and his/her participation in the project. I need each member responsibility for the project.

I will ask each member a question in the form of “What if Scenario” from your project and grade your participation in the project based on your response.

Analysis:

(Describe the problem including input and output in your own words.)

Design:

(Describe the major steps for solving the problem.)

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

package com.levelup.java.exercises.beginner;

public class ParkingTicketSimulator {

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;

}

}

/**

* This class should simulate a parking ticket, see exercise for description

* of responsibilities

*

*/

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;

}

}

/**

* This class should simulate a police officer inspecting parked cars.

*

*/

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;

}

}

/**

* This class should simulate a parking ticket.

*

*/

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 + "]";

}

}

public static void main(String[] args) {

// A green car was parked for 125 minutes

ParkingTicketSimulator parkingTicketSimulator = new ParkingTicketSimulator();

ParkedCar car = parkingTicketSimulator.new ParkedCar("Toyota", "2005",

"Green", "ABC123", 125);

// 60 minutes of time was purchased

ParkingMeter meter = parkingTicketSimulator.new ParkingMeter(60);

// Officer Jack was on duty

PoliceOfficer officer = parkingTicketSimulator.new PoliceOfficer(

"Sargent Jack Johnson", "8909");

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!");

}

}

Add a comment
Know the answer?
Add Answer to:
I need help with this java project and please follow the instruction below. thank Class Project...
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
  • Parking Ticket Simulator C++ HELP PLEASE

    For this assignment you will design a set of classes that work together to simulate a police officer issuing a parking ticket. The classes you should designare:• The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are:o To know the car’s 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 class’s only responsibility is:o To know the number...

  • 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,...

  • This is assignment and code from this site but it will not compile....can you help? home...

    This is assignment and code from this site but it will not compile....can you help? home / study / engineering / computer science / computer science questions and answers / c++ this assignment requires several classes which interact with each other. two class aggregations ... Question: C++ This assignment requires several classes which interact with each other. Two class aggregatio... (1 bookmark) C++ This assignment requires several classes which interact with each other. Two class aggregations are formed. The program...

  • using java: For this exercise, you will design a set of classes that work together to simulate a parking officer checkin...

    using java: For this exercise, you will design a set of classes that work together to simulate a parking officer checking a parked car issuing a parking ticket if there is a parking violation. Here are the classes that need to collaborate: • The ParkedCar class: This class should simulate a parked car. The car has a make, model, color, license number. •The ParkingMeter class: This class should simulate a parking meter. The class has three parameters: − A 5-digit...

  • in java PART ONE ================================================== Write a program that will read employee earnings data from an...

    in java PART ONE ================================================== Write a program that will read employee earnings data from an external file and then sort and display that data. Copy and paste the input file data below into an external file, which your program will then read. You will want to use parallel arrays for this program. Modify the select sort algorithm to receive both arrays as parameters as well as the size of the arrays. Use the algorithm to sort your earnings array....

  • This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to...

    This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...

  • Use the description from Parking Ticket Simulator from Chapter 14 as a basis, where you need...

    Use the description from Parking Ticket Simulator from Chapter 14 as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example in the PPT) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked beyond their time...

  • I need help with the following: A) create a domain class diagram for the ticket-processing system...

    I need help with the following: A) create a domain class diagram for the ticket-processing system based on the four classes (Driver, Officer, Ticket, and Court). Be sure to include attributes, association, and multiplicity. B) Be sure to list the classes that would be involved in the use cases. C) A set of CRC cards showing the classes, responsibilities, and collaborations for the use case.

  • *** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J...

    *** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J IN CLASS (IF IT DOESNT MATTER PLEASE COMMENT TELLING WHICH PROGRAM YOU USED TO WRITE THE CODE, PREFERRED IS BLUE J!!)*** ArrayList of Objects and Input File Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList<Car> list . Program should work for input file containing info...

  • I need help with this C++ code for my programming class. Thank You! You own EasyButCostly...

    I need help with this C++ code for my programming class. Thank You! You own EasyButCostly Parking Garage. Write a program to calculate the parking fees based on the number of hours a car is parked in your EasyButCostly Parking Garage. You will read in the number of hours from the user into a variable of type double and output the parking fees. The parking fees are charged as follows: Hours Fees up to 5 $10 more than 5 but...

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
ADVERTISEMENT