I need somehelp with this programing challenge problem that should be written in
ID: 3771689 • Letter: I
Question
I need somehelp with this programing challenge problem that should be written in c++ ; the problem description is as follow: please help me with this problem to be run in the c++.
I need somehelp with this programing challenge problem that should be written in c++ ; the problem description is as follow: please help me with this problem to be run in the c++.
Design the following set of classes so that they work together to simulate a police officer issuing a parking ticket. A- The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are: 1- To know the car’s make, model, color, license number, and the number of minutes that the car has been parked. B- The ParkingMeter Class: This class should simulate a parking meter. The class’s only responsibility is:2- To know the number of minutes of parking time that has been purchased. C- The ParkingTicket Class: This class should simulate a parking ticket. The class’s responsibilities are:3- To report the make, model, color, and license number of the illegally parked car 4-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 5- To report the name and badge number of the police officer issuing the ticket D- The PoliceOfficer Class: This class should simulate a police officer inspecting parked cars. The class’s responsibilities are: 6-To know the police officer’s name and badge number 7- To examine a ParkedCar object and a ParkingMeter object, and determine whether the car’s time has expired 8- 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.
Explanation / Answer
Here is the code for you. If you need any further refinements, just get back to me.
#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);
}