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 first:
The ParkedCar Class: This class should represent a parked car. The classs responsibilities are as follows:
To know the cars make, model, color, license number, and the number of minutes the car has been parked.
The ParkingMeter Class: This class should simulate a parking meter. An Object of ParkedCar will be parked near a ParkingMeter. The ParkedCar will purchase a certain amount of minutes using the 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 class responsibilities are as follows:
To report the make, model, color, and license plate number of the illegally parked Car.
To report the amount of fine, which is $25 for the first hour or part of an hour that the car has 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.
Generate UML diagram that represent the four classes and the interactions (indicate if it is dependency, aggregation, composition, or association).
Write a demo class ParkingSimulation that will demonstrate how these classes interact.
First create an object of a Police Officer (just give the officer a name and badge number).
Read a file (car.txt) that contains information on a list of parked cars along with the parking meter. You should create objects that represent the parked cars and corresponding parking meters and store them in two separate data structures.
The police officer should inspect each parked car and its corresponding meter and issue a parking ticket. If the car is parked legally, no parking ticket is issued.
Display the parking tickets in ascending order of amount of fine.
Keep track of the number of cars that got a parking ticket. Display the count.
Keep track of the total amount of money from all the parking tickets. Display the amount.
An example car.txt file is given below (col1: make, col2: model, col3: license plate, col4: minutes parked, col5: minutes purchased)
Chevrolet | Camaro | RV946 | 83 | 120 |
Kia | Soul | QY229 | 72 | 196 |
Toyota | Camry | PM506 | 50 | 126 |
Ford | Focus | FC938 | 112 | 91 |
Ford | Explorer | BA916 | 36 | 171 |
Ford | Everest | UQ848 | 57 | 195 |
Kia | Sorrento | BW108 | 55 | 108 |
Toyota | Corolla | PD527 | 103 | 107 |
Toyota | Rav4 | XS146 | 68 | 175 |
Toyota | Yaris | FY445 | 103 | 121 |
Chevrolet | Spark | QU405 | 87 | 144 |
Chevrolet | Malibu | FT808 | 37 | 129 |
Kia | Optima | CV035 | 93 | 170 |
Kia | Sedona | FT949 | 67 | 144 |
Honda | Civic | QA648 | 116 | 91 |
Honda | Accord | DL815 | 93 | 119 |
Honda | CR-V | BM519 | 88 | 125 |
Mazda | MX-5 | XB118 | 31 | 143 |
Mazda | CX-5 | VB048 | 64 | 108 |
Subaru | Legacy | XD416 | 105 | 153 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started