Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

14. Parking Ticket Simulator For this assignment you will design a set of classe

ID: 3827136 • Letter: 1

Question

14. 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. The classes you should design are:
• The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities
are:
– 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:
– 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:
– 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:
– 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
Write a program that demonstrates how these classes collaborate.

PLEASE IF U CAN THE CLASS in C++ WITH .h, .cpp and main.cpp.

thanks

Explanation / Answer

#include <iostream>
#include <cmath>
using namespace std;

class ParkedCar
{
string make;
string model;
string color;
string licenseNumber;
int minutesParked;
public:
ParkedCar()
{
make = "Ford";
model = "Figo";
color = "Red";
licenseNumber = "TX041234";
minutesParked = 0;
}
void setMake(string m)         { make = m; }
void setModel(string m)            { model = m; }
void setColor(string c)           { color = c; }
void setLicenseNumber(string l)   { licenseNumber = l; }
void setMinutesParked(int n)       { minutesParked = n; }
string getMake()                   { return make; }
string getModel()               { return model; }
string getColor()               { return color; }
string getLicenseNumber()       { return licenseNumber; }
int getMinutesParked()           { return minutesParked; }
};
class ParkingMeter
{
ParkedCar pc;
int minutesPurchased;
  
public:
ParkingMeter(ParkedCar car, int minutes)
{
pc = car;
minutesPurchased = minutes;
}
void setMinutesPurchased(int m)   { minutesPurchased = m; }
int getMinutesPurchased()       { return minutesPurchased; }
void setParkedCar(ParkedCar p) { pc = p; }
ParkedCar getParkedCar()        { return pc; }
};
class PoliceOfficer
{
string policeName;
int badgeNumber;
public:
PoliceOfficer(string name, int num)
{
policeName = name;
badgeNumber = num;
}
void setPoliceName(string name)   { policeName = name; }
void setBadgeNumber(int num)       { badgeNumber = num; }
string getPoliceName()           { return policeName; }
int getBadgeNumber()               {return badgeNumber; }
ParkingTicket examineCarMeter(ParkingMeter parkingMeter)
{
ParkedCar pc = parkingMeter.getParkedCar();
int x = parkingMeter.pc.getMinutesParked() - parkingMeter.getMinutesPurchased();
if(x > 0)
{
ParkingTicket pTicket (pc, this, x);
}
else
{
cout<<"Parking Ticket not required."<<endl;
}
}
};
class ParkingTicket
{
ParkedCar car;
PoliceOfficer police;
int        fineMinutes;
public:
ParkingTicket(ParkedCar pc, PoliceOfficer po, int min)
{
car = pc;
police = po;
fineMinutes = min;
}
int calculateFineAmount()
{
if(fineMinutes <= 60)
return 25;
else
{
return 25 + ceil((fineMinutes - 60)/60.0) * 10;
}
}
};

int main()
{
ParkedCar p;
ParkingMeter pm (p, 10);
PoliceOfficer po ("Kumar", 222);
po.examineCarMeter (pm);
}
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote