PARKING TICKET SIMULATOR

So here's the thing...I'm working on a program called Parking Ticket Simulator, but for reasons that I cannot grasp, the program isn't running properly...I will be posting part of the code where I think I'm making the errors...Thanks in advance for your assistance.

instructions

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

P.S. I'm still learning c++, so if you see abnormalities please be nice...lol



ParkingTicket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  #pragma once
#include<iostream>
#include"ParkedCar.h"
#include"ParkingMeter.h"
#include"PoliceOfficer.h"
#include<string>
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include<iostream>
#include"ParkingTicket.h"
#include"ParkingMeter.h"
#include"ParkedCar.h"
#include<string>

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include"ParkedCar.h"
#include"ParkingMeter.h"
#include"ParkingTicket.h"
#include"PoliceOfficer.h"
#include<iostream>
#include<string>
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;
	}
}

Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<iostream>
#include"ParkingTicket.h"
#include"ParkingMeter.h"
#include"ParkedCar.h"
#include"PoliceOfficer.h"
#include<string>

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;



}

Last edited on
closed account (48T7M4Gy)
Please remove your multiple posts
http://www.cplusplus.com/forum/general/214517/
Topic archived. No new replies allowed.