Question

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 of minutes of parking time that has been purchased
• The ParkingTicket Class: This class should simulate a parking ticket. The class’s responsibilities are:
o To report the make, model, color, and license number of the illegally parked car
o 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 partof an hour that the car is illegally parked
o 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:
o To know the police officer’s name and badge number
o To examine a ParkedCar object and a ParkingMeter object, and determine whether the car’s time has expired
o To issue a parking ticket (generate a ParkingTicket object) if the car’s time has expired

Demonstrate the class in a driver program, the Parking.cpp file, by completing the following:

1. Create a ParkingTicket pointer. Initialize the pointer to NULL because no ticket has been issued yet.
2. Create a ParkedCar object that is initialized with the following information:
a. Make = Ford
b. Model = Mustang
c. Color = Purple
d. License Number = JKL123
e. Number of parked minutes = 125
3. Create a ParkingMeter object. 60minutes were purchased.
4. Create PoliceOfficer object that is initialized with the following information:
a. Name = Susie May
b. Badge Number = 4788
5. Let the officer patrol and issue tickets if necessary. Issuing a ticket should be indicated by a display on the screen.


PLease help!

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

ParkedCar.h:

#pragma once
#include
#include
using namespace std;
class ParkedCar
{
private:
string make;
string model;
string color;
string licensenumber;
int parkedminutes;

public:
ParkedCar();
ParkedCar(string, string, string, string, int);
~ParkedCar();
void setmake(string);
void setmodel(string);
void setcolor(string);
void setlicensenumber(string);
void setparkedminutes(int);
void set(string, string, string, string, int);

string getmake() const;
string getmodel()const;
string getcolor()const;
string getlicensenumber()const;
int getparkedminutes()const;
void parkedcardisplay() const;
};

ParkedCar.cpp:

#include"ParkedCar.h"
ParkedCar::ParkedCar()
{
make=" ";
model = " ";
color = " ";
licensenumber = " ";
parkedminutes = 0;
}
ParkedCar::ParkedCar(string amake, string amodel, string acolor, string alicensenumber, int aparkedminutes)
{
make = amake;
model = amodel ;
color = acolor;
licensenumber = alicensenumber;
parkedminutes = aparkedminutes;
}
ParkedCar::~ParkedCar() {}
void ParkedCar::setmake(string amake)
{
make = amake;
}
void ParkedCar::setmodel(string amodel)
{
model = amodel;
  
}
void ParkedCar::setcolor(string acolor)
{
color = acolor;
  
}
void ParkedCar::setlicensenumber(string alicensenumber)
{
licensenumber = alicensenumber;
  
}
void ParkedCar::setparkedminutes(int aparkedminutes)
{
parkedminutes = aparkedminutes;
}
void ParkedCar::set(string amake, string amodel, string acolor, string alicensenumber, int aparkedminutes)
{
make = amake;
model = amodel;
color = acolor;
licensenumber = alicensenumber;
parkedminutes = aparkedminutes;
}

string ParkedCar::getmake() const
{
return make;
}
string ParkedCar::getmodel()const
{
return model;
}
string ParkedCar::getcolor()const
{
return color;
}
string ParkedCar::getlicensenumber()const
{
return licensenumber;
}
int ParkedCar::getparkedminutes()const
{
return parkedminutes;
}
void ParkedCar::parkedcardisplay() const
{
cout << "Make: " << make << endl;
cout << "Model: " << model << endl;
cout << "Color: " << color << endl;
cout << "License Number: " << licensenumber << endl;
}

ParkingMeter.h:

#pragma once
//#include"ParkedCar.h"
//#include"ParkingTicket.h"
//#include"PoliceOfficer.h"
#include
using namespace std;
class ParkingMeter {
private:
int minutespurchased;
public:
ParkingMeter();
ParkingMeter(int);
~ParkingMeter();
void setparkingmeter(int);
int getparkingmeter() const;
};

ParkingMeter.cpp:

#include"ParkingMeter.h"

ParkingMeter::ParkingMeter()
{
minutespurchased = 0;
}
ParkingMeter::ParkingMeter(int aminutespurchased)
{
minutespurchased = aminutespurchased;
}
ParkingMeter::~ParkingMeter() {}
void ParkingMeter::setparkingmeter(int aminutespurchased)
{
minutespurchased = aminutespurchased;
}
int ParkingMeter::getparkingmeter() const
{
return minutespurchased;
}

ParkingTicket.h:

#pragma once
#include
#include"ParkedCar.h"
#include"ParkingMeter.h"
#include"PoliceOfficer.h"
#include
using namespace std;
class ParkingTicket {
private:
int fine;
ParkingMeter PM;
ParkedCar PC;
PoliceOfficer PO;

public:
ParkingTicket();
ParkingTicket(string aname, string abadge, string amake, string amodel, string acolor, string alicensenumber, int aparkedminutes, int aminutespurchased);
~ParkingTicket();
int getfine() const;
void generateticket();
void reportCarInfo();
void reportfine();
void reportOfficer();

};

ParkingTicket.cpp:

#include"ParkingTicket.h"
ParkingTicket::ParkingTicket()
{
fine = 0;
}
ParkingTicket::ParkingTicket(string aname, string abadge, string amake, string amodel, string acolor, string alicensenumber, int aparkedminutes, int aminutespurchased)
{
PC.set(amake, amodel, acolor, alicensenumber, aparkedminutes);
PM.setparkingmeter(aminutespurchased);
PO.setOfficer(aname, abadge);
}
ParkingTicket::~ParkingTicket()
{
}
void ParkingTicket::reportCarInfo()
{
PC.parkedcardisplay();
}
void ParkingTicket::reportfine()
{
int illegaltime = PC.getparkedminutes() - PM.getparkingmeter();
if (illegaltime> 0 && illegaltime <= 60) {
fine = 25;
}
else {
if (illegaltime > 60)
{
int temp = illegaltime;
fine = 25;
while (temp > 0 || temp > 60)
{
fine += 10;
temp -= 60;
}
}
}
cout << "Fine: $" << getfine() << endl;
}
void ParkingTicket::reportOfficer()
{
PO.displayofficer();
}
int ParkingTicket::getfine() const
{
return fine;
}

void ParkingTicket::generateticket()
{
cout << endl;
cout << "-----------------------------" << endl;
cout << " ~ILLEGAL PARKING TICKET~" << endl;
cout << "-----------------------------" << endl;
reportCarInfo();
reportfine();
reportOfficer();
cout << endl;
}

PoliceOfficer.h:

#pragma once
#include
#include"ParkingTicket.h"
#include"ParkingMeter.h"
#include"ParkedCar.h"
#include
using namespace std;

class PoliceOfficer {

private:
string name;
string badge;
ParkingMeter PM;
ParkedCar PC;
  

public:
PoliceOfficer();
PoliceOfficer(string aname, string abadge, string amake, string amodel, string acolor, string alicensenumber, int aparkedminutes, int aminutespurchased);
~PoliceOfficer();
void setname(string);
void setbadge(string);
void setOfficer(string, string);
string getname() const;
string getbadge() const;
void patrol();
void displayofficer() const;
};

PoliceOfficer.cpp:

#include"ParkedCar.h"
#include"ParkingMeter.h"
#include"ParkingTicket.h"
#include"PoliceOfficer.h"
#include
#include
using namespace std;

PoliceOfficer::PoliceOfficer()
{
  
badge = " ";
name = " ";
}
PoliceOfficer::PoliceOfficer(string aname, string abadge, string amake, string amodel, string acolor, string alicensenumber, int aparkedminutes, int aminutespurchased)
{
PC.set(amake, amodel, acolor, alicensenumber, aparkedminutes);
PM.setparkingmeter(aminutespurchased);
setOfficer(aname, abadge);
}
PoliceOfficer::~PoliceOfficer()
{
}

void PoliceOfficer::setname(string aname)
{
name = aname;
}
void PoliceOfficer::setbadge(string abadge)
{
badge = abadge;
}
void PoliceOfficer::setOfficer(string aname, string abadge)
{
badge = abadge;
name = aname;
}
string PoliceOfficer::getname() const
{
return name;
}
string PoliceOfficer::getbadge() const
{
return badge;
}
void PoliceOfficer::displayofficer() const
{
cout << "Name: " << getname() << endl;
cout << "Badge ID: " << getbadge() << endl;
}
void PoliceOfficer::patrol()
{
if (PC.getparkedminutes() > PM.getparkingmeter()) /*parked minutes >= minutes purchased*/
{
ParkingTicket PT;
PT.generateticket();
}
else
{
cout << "No crime has been commited." << endl;
}
}

MainClass.cpp

#include
#include"ParkingTicket.cpp"
#include"ParkingMeter.cpp"
#include"ParkedCar.cpp"
#include"PoliceOfficer.cpp"
//#include
using namespace std;

int main()
{
int option;
PoliceOfficer officer;
ParkedCar car;
ParkingMeter meter;
do {
string aname, abadge, amake, amodel, alicensenumber, acolor;
int aminutespurchased, aparkedminutes;
  
cout << "--------------------------------" << endl;
cout << " ~Parking Ticket Simulator~" << endl;
cout << "--------------------------------" << endl;
cout << endl;
cout << "Vehicle Information:" << endl;
cout << "Make: ";
getline(cin, amake);
cout << "Model: ";
getline(cin, amodel);
cout << "Color: ";
getline(cin, acolor);
cout << "License Number: ";
getline(cin, alicensenumber);
cout << "Parked Minutes: ";
cin>> aparkedminutes;
car.set(amake, amodel, acolor, alicensenumber, aparkedminutes);
cout << "Minutes Purchased: ";
cin >> aminutespurchased;
meter.setparkingmeter(aminutespurchased);
cout << endl;
cout << "Officer Information:" << endl;
cout << "Name: ";
getline(cin, aname);
cout << "Badge ID: ";
getline(cin, abadge);
officer.setOfficer(aname, abadge);
system("cls");
officer.patrol();
cout << endl;
cout << "Enter 0 to exit or any number to restart: ";
cin >> option;
} while (option != 0);
system("pause");
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Parking Ticket Simulator C++ HELP PLEASE
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 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,...

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

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

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

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

  • PART TWO Write a program which will populate an integer ArrayList with user input, and then...

    PART TWO Write a program which will populate an integer ArrayList with user input, and then provide a menu of various operations to perform on that ArrayList. The first step is to have the user push a bunch of integers into a ArrayList. The second step is to perform various operations on that ArrayList. Your input must be in the format below. The user can enter either a positive integer or -99 to quit. The menu to present is: Sum...

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

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

  • Project: Parking Ticket Simulator Problem Description: For this assignment you will design a set of classes that work...

    Project: Parking Ticket Simulator Problem Description: 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:

  • C# Car Instrument Simulation (Updated Question) Car Instrument Simulator Design a set of classes that work...

    C# Car Instrument Simulation (Updated Question) Car Instrument Simulator Design a set of classes that work together to simulate a car’s fuel gauge and odometer. The classes you will design are the following: • The FuelGauge Class: This class will simulate a fuel gauge. Its responsibilities are as follows: o To know the car’s current amount of fuel, in liters. o To report the car’s current amount of fuel, in liters. o To be able to increment the amount of...

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