SlideShare a Scribd company logo
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 bene
purchased.
· The ParkingTicket Class: The 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 $01 for
every additional hour or part of an hour that the car is illegally
parked 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 responsibility are:
· To know the police office’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 hoe the classes collaborate.
Assignment Details
Case Study: Sergeant Lou Maynard
CJ345-2: Evaluate the implementation of problem-oriented
policing within criminal justice entities.
Before starting this assignment, please take a few minutes and
complete the practice learning activity associated with this
outcome.
Write a 2–4-page paper (excluding cover page) responding to
the following:
Read the case study on page 103 in Effective Police Supervision
and apply critical thinking to construct persuasive arguments as
to what you would you do if you were Sergeant Lou Maynard.
Use the questions at the end of the case study to help you
construct your paper and be sure to address the following:
1. Describe the motivational issues that exist.
2. The basic need drives for each officer.
3. Assess your management style and how it relates to Theory
X.
4. If your level of formal education, or the education of the
officers, would be an obstacle.
For assistance with this Assignment, refer to Chapter 4 of your
text.
(PLEASE NOTE: This essay may require outside research.)
You may consult the Kaplan Online Library, the internet, the
textbook, other course material, and any other outside resources
in supporting your task, using proper citations in APA style.
Directions for Submitting Your Case Study
Write your essay in a Word document and save it in a location
and with a name that you will remember. Be sure to include
your name, class, and section number in your essay. Submit
your Assignment by selecting the Unit 2: Assignment in the
Dropbox by the end of Unit 2.
Parking Ticket Code/ParkedCar.cppParking Ticket
Code/ParkedCar.cpp// Implementation file for the ParkedCar cla
ss
#include<iostream>
#include"ParkedCar.h"
usingnamespace std;
// Default Constructor
ParkedCar::ParkedCar()
{
make ="";
model ="";
color ="";
licenseNumber ="";
minutesParked =0;
}
// Constructor
// Parameters:
// mk The car's make.
// mod The car's model.
// col The car's color.
// lic The car's license number.
// min The number of minutes parked.
ParkedCar::ParkedCar(string mk, string mod, string col,
string lic,int min)
{
make = mk;
model = mod;
color = col;
licenseNumber = lic;
minutesParked = min;
}
// Copy constructor
ParkedCar::ParkedCar(constParkedCar&car2)
{
make = car2.make;
model = car2.model;
color = car2.color;
licenseNumber = car2.licenseNumber;
minutesParked = car2.minutesParked;
}
// print function
voidParkedCar::print()
{
cout <<"Car Information:n";
cout <<"tMake: "<< make << endl;
cout <<"tmodel: "<< model << endl;
cout <<"tColor: "<< color << endl;
cout <<"tLicense Number: "<< licenseNumber << endl;
cout <<"tMinutes Parked: "<< minutesParked << endl;
}
Parking Ticket Code/ParkedCar.h
// Specification file for the ParkedCar class
#ifndef PARKED_CAR_H
#define PARKED_CAR_H
#include<string>
using namespace std;
// ParkedCar class
class ParkedCar
{
private:
string make; // The car's make
string model; // The car's model
string color; // The car's color
string licenseNumber; // The car's license number
int minutesParked; // Minutes parked
public:
// Default constructor
ParkedCar();
// Constructor
ParkedCar(string, string, string, string, int);
// Copy constructor
ParkedCar(const ParkedCar &);
// Mutators
void setMake(string m)
{ make = m; }
void setModel(string m)
{ model = m; }
void setColor(string c)
{ color = c; }
void setLicenseNumber(string lic)
{ licenseNumber = lic; }
void setMinutesParked(int m)
{ minutesParked = m; }
// Accessors
string getMake() const
{ return make; }
string getModel() const
{ return model;}
string getColor() const
{ return color; }
string getLicenseNumber() const
{ return licenseNumber; }
int getMinutesParked() const
{ return minutesParked; }
// print function
void print();
};
#endif
Parking Ticket Code/ParkingMeter.h
// Specification file for the ParkingMeter class
#ifndef PARKING_METER_H
#define PARKING_METER_H
#include <iostream>
using namespace std;
// ParkingMeter class
class ParkingMeter
{
private:
int minutesPurchased; // Minutes purchased
public:
// Default constructor
ParkingMeter()
{ minutesPurchased = 0; }
// Constructor. The parameter m is
// the number of minutes purchased.
ParkingMeter(int m)
{ minutesPurchased = m; }
// Mutator
void setMinutesPurchased(int m)
{ minutesPurchased = m; }
// Accessor
int getMinutesPurchased() const
{ return minutesPurchased; }
// print function
void print()
{ cout << "Meter Information:n";
cout << "tMinutes Purchases: "
<< minutesPurchased << endl;
}
};
#endif
Parking Ticket Code/ParkingTicket.cppParking Ticket
Code/ParkingTicket.cpp// Implementation file for the ParkingTi
cket class
#include"ParkingTicket.h"
#include<iostream>
#include<iomanip>
usingnamespace std;
// Default constructor
ParkingTicket::ParkingTicket()
{
fine =0.0;
minutes =0;
}
// Constructor
// Parameters:
// aCar - A ParkedCar object.
// min - Minutes illegally parked.
ParkingTicket::ParkingTicket(ParkedCar aCar,int min)
{
car = aCar;
minutes = min;
// Calculate the fine.
calculateFine();
}
// Copy constructor
ParkingTicket::ParkingTicket(constParkingTicket&ticket2)
{
car = ticket2.car;
fine = ticket2.fine;
}
// calculateFine method
// This method calculates the amount of the parking fine.
voidParkingTicket::calculateFine()
{
// Get the time parked in hours.
double hours = minutes /60.0;
// Get the hours as an int.
int hoursAsInt =static_cast<int>(hours);
// If there was a portion of an hour, round up.
if((hours - hoursAsInt)>0)
hoursAsInt++;
// Assign the base fine.
fine = BASE_FINE;
// Add the additional hourly fines.
fine +=(hoursAsInt * HOURLY_FINE);
}
// print function
voidParkingTicket::print()
{
// Print car information.
car.print();
// Print ticket information.
cout <<"Ticket Information:n";
cout <<"tMinutes in violation: "<< minutes << endl;
cout <<"tFine: $ "<< setprecision(2)<< fixed
<< showpoint << fine << endl;
}
Parking Ticket Code/ParkingTicket.h
// Specification file for the ParkingTicket class
#ifndef PARKING_TICKET_H
#define PARKING_TICKET_H
#include "ParkedCar.h"
// Constant for the base fine.
const double BASE_FINE = 25.0;
// Constant for the additional hourly fine.
const double HOURLY_FINE = 10.0;
// ParkingTicket class
class ParkingTicket
{
private:
ParkedCar car; // The parked car
double fine; // The parking fine
int minutes; // Minutes illegally parked
// calculateFine method
// This method calculates the amount of the parking fine.
void calculateFine();
public:
// Default Constructor
ParkingTicket();
// Constructor
ParkingTicket(ParkedCar, int);
// Copy constructor
ParkingTicket(const ParkingTicket &);
// Mutators
void setCar(ParkedCar c)
{
car = c;
}
void setMinutes(int m)
{
minutes = m;
}
// Accessors
ParkedCar getCar() const
{
return car;
}
double getFine() const
{
return fine;
}
// print function
void print();
};
#endif
Parking Ticket Code/PoliceOfficer.cppParking Ticket
Code/PoliceOfficer.cpp// Implementation file for the PoliceOffi
cer class
#include"ParkedCar.h"
#include"ParkingMeter.h"
#include"ParkingTicket.h"
#include"PoliceOfficer.h"
#include<iostream>
usingnamespace std;
// The patrol function looks at the number of
// minutes a car has been parked and the number
// of minutes purchased. If the minutes parked is
// greater than the minutes purchased, a pointer
// to a ParkingTicket object is returned. Otherwise
// the function returns a nullptr.
ParkingTicket*PoliceOfficer::patrol(ParkedCar car,ParkingMete
r meter)
{
// Get the minutes parked over the amount purchased.
int illegalMinutes = car.getMinutesParked()-
meter.getMinutesPurchased();
// Determine whether the car is illegally parked.
if(illegalMinutes >0)
{
// Yes, it is illegally parked.
// Create a ParkingTicket object.
ticket =newParkingTicket(car, illegalMinutes);
}
// Return the ticket, if any.
return ticket;
}
// print function
voidPoliceOfficer::print()
{
cout <<"Police Officer Information:n";
cout <<"tName: "<< name << endl;
cout <<"tBadge Number: "<< badgeNumber << endl;
}
Parking Ticket Code/PoliceOfficer.h
// Specification file for the PoliceOfficer class
#ifndef POLICE_OFFICER_H
#define POLICE_OFFICER_H
#include "ParkedCar.h"
#include "ParkingMeter.h"
#include "ParkingTicket.h"
// PoliceOfficer class
class PoliceOfficer
{
private:
string name; // Officer's name
string badgeNumber; // Badge number
ParkingTicket *ticket; // Pointer to a ticket
public:
// Default constructor
PoliceOfficer()
{ name = ""; badgeNumber = ""; ticket = nullptr; }
// Constructor
// The parameter n is the officer's name.
// The parameter bn is the officer's badge number.
PoliceOfficer(string n, string bn)
{
name = n;
badgeNumber = bn;
ticket = nullptr;
}
// Copy constructor
PoliceOfficer(const PoliceOfficer &officer2)
{
name = officer2.name;
badgeNumber = officer2.badgeNumber;
ticket = new ParkingTicket(*officer2.ticket);
}
// Mutators
void setName(string n)
{
name = n;
}
void setBadgeNumber(string b)
{
badgeNumber = b;
}
// Accessors
string getName()
{
return name;
}
string getBadgeNumber()
{
return badgeNumber;
}
// patrol function
ParkingTicket *patrol(ParkedCar, ParkingMeter);
// print function
void print();
};
#endif
Parking Ticket Code/spc14-14.cppParking Ticket Code/spc14-
14.cpp// Chapter 14, Programming Challenge 14: Parking Ticket
Simulator
#include<iostream>
#include"ParkedCar.h"
#include"ParkingMeter.h"
#include"ParkingTicket.h"
#include"PoliceOfficer.h"
usingnamespace std;
int main()
{
// Create a ParkingTicket pointer. If a parking ticket
// is issued, this will point to it.
ParkingTicket*ticket =nullptr;
// Create a ParkedCar object.
// The car was parked for 125 minutes.
ParkedCar car("Volkswagen","1972","Red","147RHZM",125);
// Create a ParkingMeter object.
// 60 minutes were purchased.
ParkingMeter meter(60);
// Create a PoliceOfficer object.
PoliceOfficer officer("Joe Friday","4788");
// Let the officer patrol.
ticket = officer.patrol(car, meter);
if(ticket !=nullptr)
{
// Display the officer information.
officer.print();
// Display the ticket information.
ticket->print();
// We're done with the ticket, so delete it.
delete ticket;
ticket =nullptr;
}
else
cout <<"No crimes were committed.n";
return0;
}

More Related Content

Similar to Parking Ticket SimulatorFor this assignment you will design a se.docx

Assignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdfAssignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdf
fasttrackscardecors
 
(7) cpp abstractions inheritance_part_ii
(7) cpp abstractions inheritance_part_ii(7) cpp abstractions inheritance_part_ii
(7) cpp abstractions inheritance_part_ii
Nico Ludwig
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdf
ajantha11
 
#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docx#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docx
mayank272369
 
(5) c sharp introduction_object_orientation_part_ii
(5) c sharp introduction_object_orientation_part_ii(5) c sharp introduction_object_orientation_part_ii
(5) c sharp introduction_object_orientation_part_ii
Nico Ludwig
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
vinodagrawal6699
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
D. j Vicky
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
D. j Vicky
 
C# Programming Help
C# Programming HelpC# Programming Help
C# Programming Help
Programming Homeworks Help
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdf
arsmobiles
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
Volumetric efficiency  calculating your cars volumetric efficiency
Volumetric efficiency  calculating your cars volumetric efficiencyVolumetric efficiency  calculating your cars volumetric efficiency
Volumetric efficiency  calculating your cars volumetric efficiencyZulkarnian Nasrulllah
 
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docxCOIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
clarebernice
 
C++ Program Auto workshop service system
C++ Program Auto workshop service systemC++ Program Auto workshop service system
C++ Program Auto workshop service system
Shahzaib Farooq
 
cbse 12 computer science IP
cbse 12 computer science IPcbse 12 computer science IP
cbse 12 computer science IP
D. j Vicky
 
AUTOMATIC SOLAR VERTICAL CAR PARKING SYSTEM
      AUTOMATIC  SOLAR VERTICAL CAR PARKING SYSTEM      AUTOMATIC  SOLAR VERTICAL CAR PARKING SYSTEM
AUTOMATIC SOLAR VERTICAL CAR PARKING SYSTEM
Mirza Baig
 
Iaetsd fpga implementation of various security based tollgate system using anpr
Iaetsd fpga implementation of various security based tollgate system using anprIaetsd fpga implementation of various security based tollgate system using anpr
Iaetsd fpga implementation of various security based tollgate system using anpr
Iaetsd Iaetsd
 
Standoutfromthe crowds
Standoutfromthe crowdsStandoutfromthe crowds
Standoutfromthe crowds
Mohammed Awad
 
I need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdfI need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdf
adianantsolutions
 
Code and Design Smells. Are They a Real Threat?
Code and Design Smells. Are They a Real Threat?Code and Design Smells. Are They a Real Threat?
Code and Design Smells. Are They a Real Threat?
GlobalLogic Ukraine
 

Similar to Parking Ticket SimulatorFor this assignment you will design a se.docx (20)

Assignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdfAssignment DIn Problem D1 we will use a file to contain the dat.pdf
Assignment DIn Problem D1 we will use a file to contain the dat.pdf
 
(7) cpp abstractions inheritance_part_ii
(7) cpp abstractions inheritance_part_ii(7) cpp abstractions inheritance_part_ii
(7) cpp abstractions inheritance_part_ii
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdf
 
#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docx#include iostream#include string#include iomanip#inclu.docx
#include iostream#include string#include iomanip#inclu.docx
 
(5) c sharp introduction_object_orientation_part_ii
(5) c sharp introduction_object_orientation_part_ii(5) c sharp introduction_object_orientation_part_ii
(5) c sharp introduction_object_orientation_part_ii
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 
C# Programming Help
C# Programming HelpC# Programming Help
C# Programming Help
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdf
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Volumetric efficiency  calculating your cars volumetric efficiency
Volumetric efficiency  calculating your cars volumetric efficiencyVolumetric efficiency  calculating your cars volumetric efficiency
Volumetric efficiency  calculating your cars volumetric efficiency
 
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docxCOIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
 
C++ Program Auto workshop service system
C++ Program Auto workshop service systemC++ Program Auto workshop service system
C++ Program Auto workshop service system
 
cbse 12 computer science IP
cbse 12 computer science IPcbse 12 computer science IP
cbse 12 computer science IP
 
AUTOMATIC SOLAR VERTICAL CAR PARKING SYSTEM
      AUTOMATIC  SOLAR VERTICAL CAR PARKING SYSTEM      AUTOMATIC  SOLAR VERTICAL CAR PARKING SYSTEM
AUTOMATIC SOLAR VERTICAL CAR PARKING SYSTEM
 
Iaetsd fpga implementation of various security based tollgate system using anpr
Iaetsd fpga implementation of various security based tollgate system using anprIaetsd fpga implementation of various security based tollgate system using anpr
Iaetsd fpga implementation of various security based tollgate system using anpr
 
Standoutfromthe crowds
Standoutfromthe crowdsStandoutfromthe crowds
Standoutfromthe crowds
 
I need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdfI need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdf
 
Code and Design Smells. Are They a Real Threat?
Code and Design Smells. Are They a Real Threat?Code and Design Smells. Are They a Real Threat?
Code and Design Smells. Are They a Real Threat?
 

More from danhaley45372

Your initial post should be 2-3 paragraphs in length.Inclu.docx
Your initial post should be 2-3 paragraphs in length.Inclu.docxYour initial post should be 2-3 paragraphs in length.Inclu.docx
Your initial post should be 2-3 paragraphs in length.Inclu.docx
danhaley45372
 
Your initial post should be made during Unit 2,  January 21st at 4.docx
Your initial post should be made during Unit 2,  January 21st at 4.docxYour initial post should be made during Unit 2,  January 21st at 4.docx
Your initial post should be made during Unit 2,  January 21st at 4.docx
danhaley45372
 
Your initial post should be at least 450+ words and in APA forma.docx
Your initial post should be at least 450+ words and in APA forma.docxYour initial post should be at least 450+ words and in APA forma.docx
Your initial post should be at least 450+ words and in APA forma.docx
danhaley45372
 
Your initial post should be made during Unit 2, january 21st at 4.docx
Your initial post should be made during Unit 2, january 21st at 4.docxYour initial post should be made during Unit 2, january 21st at 4.docx
Your initial post should be made during Unit 2, january 21st at 4.docx
danhaley45372
 
Your initial post should be made during, Submissions after this time.docx
Your initial post should be made during, Submissions after this time.docxYour initial post should be made during, Submissions after this time.docx
Your initial post should be made during, Submissions after this time.docx
danhaley45372
 
Your essay should address the following.(a) How  is the biologic.docx
Your essay should address the following.(a) How  is the biologic.docxYour essay should address the following.(a) How  is the biologic.docx
Your essay should address the following.(a) How  is the biologic.docx
danhaley45372
 
Your initial post is due by midnight (1159 PM) on Thursday. You mus.docx
Your initial post is due by midnight (1159 PM) on Thursday. You mus.docxYour initial post is due by midnight (1159 PM) on Thursday. You mus.docx
Your initial post is due by midnight (1159 PM) on Thursday. You mus.docx
danhaley45372
 
Your individual sub-topic written (MIN of 1, MAX 3 pages)You.docx
Your individual sub-topic written (MIN of 1, MAX 3 pages)You.docxYour individual sub-topic written (MIN of 1, MAX 3 pages)You.docx
Your individual sub-topic written (MIN of 1, MAX 3 pages)You.docx
danhaley45372
 
Your HR project to develop a centralized model of deliveri.docx
Your HR project to develop a centralized model of deliveri.docxYour HR project to develop a centralized model of deliveri.docx
Your HR project to develop a centralized model of deliveri.docx
danhaley45372
 
Your Immersion Project for this course is essentially ethnographic r.docx
Your Immersion Project for this course is essentially ethnographic r.docxYour Immersion Project for this course is essentially ethnographic r.docx
Your Immersion Project for this course is essentially ethnographic r.docx
danhaley45372
 
Your country just overthrew its dictator, and you are the newly .docx
Your country just overthrew its dictator, and you are the newly .docxYour country just overthrew its dictator, and you are the newly .docx
Your country just overthrew its dictator, and you are the newly .docx
danhaley45372
 
Your have been contracted by HealthFirst Hospital Foundation (HHF),.docx
Your have been contracted by HealthFirst Hospital Foundation (HHF),.docxYour have been contracted by HealthFirst Hospital Foundation (HHF),.docx
Your have been contracted by HealthFirst Hospital Foundation (HHF),.docx
danhaley45372
 
Your group presentationWhat you need to do.docx
Your group presentationWhat you need to do.docxYour group presentationWhat you need to do.docx
Your group presentationWhat you need to do.docx
danhaley45372
 
Your contribution(s) must add significant information to the dis.docx
Your contribution(s) must add significant information to the dis.docxYour contribution(s) must add significant information to the dis.docx
Your contribution(s) must add significant information to the dis.docx
danhaley45372
 
Your good friends have just adopted a four-year-old child. At th.docx
Your good friends have just adopted a four-year-old child. At th.docxYour good friends have just adopted a four-year-old child. At th.docx
Your good friends have just adopted a four-year-old child. At th.docx
danhaley45372
 
Your good friends have just adopted a four-year-old child. At this p.docx
Your good friends have just adopted a four-year-old child. At this p.docxYour good friends have just adopted a four-year-old child. At this p.docx
Your good friends have just adopted a four-year-old child. At this p.docx
danhaley45372
 
Your goals as the IT architect and IT security specialist are to.docx
Your goals as the IT architect and IT security specialist are to.docxYour goals as the IT architect and IT security specialist are to.docx
Your goals as the IT architect and IT security specialist are to.docx
danhaley45372
 
Your essay should address the following problem.(a) What is .docx
Your essay should address the following problem.(a) What is .docxYour essay should address the following problem.(a) What is .docx
Your essay should address the following problem.(a) What is .docx
danhaley45372
 
Your future financial needs will be based on the income you can reas.docx
Your future financial needs will be based on the income you can reas.docxYour future financial needs will be based on the income you can reas.docx
Your future financial needs will be based on the income you can reas.docx
danhaley45372
 
Your friend Lydia is having difficulty taking in the informati.docx
Your friend Lydia is having difficulty taking in the informati.docxYour friend Lydia is having difficulty taking in the informati.docx
Your friend Lydia is having difficulty taking in the informati.docx
danhaley45372
 

More from danhaley45372 (20)

Your initial post should be 2-3 paragraphs in length.Inclu.docx
Your initial post should be 2-3 paragraphs in length.Inclu.docxYour initial post should be 2-3 paragraphs in length.Inclu.docx
Your initial post should be 2-3 paragraphs in length.Inclu.docx
 
Your initial post should be made during Unit 2,  January 21st at 4.docx
Your initial post should be made during Unit 2,  January 21st at 4.docxYour initial post should be made during Unit 2,  January 21st at 4.docx
Your initial post should be made during Unit 2,  January 21st at 4.docx
 
Your initial post should be at least 450+ words and in APA forma.docx
Your initial post should be at least 450+ words and in APA forma.docxYour initial post should be at least 450+ words and in APA forma.docx
Your initial post should be at least 450+ words and in APA forma.docx
 
Your initial post should be made during Unit 2, january 21st at 4.docx
Your initial post should be made during Unit 2, january 21st at 4.docxYour initial post should be made during Unit 2, january 21st at 4.docx
Your initial post should be made during Unit 2, january 21st at 4.docx
 
Your initial post should be made during, Submissions after this time.docx
Your initial post should be made during, Submissions after this time.docxYour initial post should be made during, Submissions after this time.docx
Your initial post should be made during, Submissions after this time.docx
 
Your essay should address the following.(a) How  is the biologic.docx
Your essay should address the following.(a) How  is the biologic.docxYour essay should address the following.(a) How  is the biologic.docx
Your essay should address the following.(a) How  is the biologic.docx
 
Your initial post is due by midnight (1159 PM) on Thursday. You mus.docx
Your initial post is due by midnight (1159 PM) on Thursday. You mus.docxYour initial post is due by midnight (1159 PM) on Thursday. You mus.docx
Your initial post is due by midnight (1159 PM) on Thursday. You mus.docx
 
Your individual sub-topic written (MIN of 1, MAX 3 pages)You.docx
Your individual sub-topic written (MIN of 1, MAX 3 pages)You.docxYour individual sub-topic written (MIN of 1, MAX 3 pages)You.docx
Your individual sub-topic written (MIN of 1, MAX 3 pages)You.docx
 
Your HR project to develop a centralized model of deliveri.docx
Your HR project to develop a centralized model of deliveri.docxYour HR project to develop a centralized model of deliveri.docx
Your HR project to develop a centralized model of deliveri.docx
 
Your Immersion Project for this course is essentially ethnographic r.docx
Your Immersion Project for this course is essentially ethnographic r.docxYour Immersion Project for this course is essentially ethnographic r.docx
Your Immersion Project for this course is essentially ethnographic r.docx
 
Your country just overthrew its dictator, and you are the newly .docx
Your country just overthrew its dictator, and you are the newly .docxYour country just overthrew its dictator, and you are the newly .docx
Your country just overthrew its dictator, and you are the newly .docx
 
Your have been contracted by HealthFirst Hospital Foundation (HHF),.docx
Your have been contracted by HealthFirst Hospital Foundation (HHF),.docxYour have been contracted by HealthFirst Hospital Foundation (HHF),.docx
Your have been contracted by HealthFirst Hospital Foundation (HHF),.docx
 
Your group presentationWhat you need to do.docx
Your group presentationWhat you need to do.docxYour group presentationWhat you need to do.docx
Your group presentationWhat you need to do.docx
 
Your contribution(s) must add significant information to the dis.docx
Your contribution(s) must add significant information to the dis.docxYour contribution(s) must add significant information to the dis.docx
Your contribution(s) must add significant information to the dis.docx
 
Your good friends have just adopted a four-year-old child. At th.docx
Your good friends have just adopted a four-year-old child. At th.docxYour good friends have just adopted a four-year-old child. At th.docx
Your good friends have just adopted a four-year-old child. At th.docx
 
Your good friends have just adopted a four-year-old child. At this p.docx
Your good friends have just adopted a four-year-old child. At this p.docxYour good friends have just adopted a four-year-old child. At this p.docx
Your good friends have just adopted a four-year-old child. At this p.docx
 
Your goals as the IT architect and IT security specialist are to.docx
Your goals as the IT architect and IT security specialist are to.docxYour goals as the IT architect and IT security specialist are to.docx
Your goals as the IT architect and IT security specialist are to.docx
 
Your essay should address the following problem.(a) What is .docx
Your essay should address the following problem.(a) What is .docxYour essay should address the following problem.(a) What is .docx
Your essay should address the following problem.(a) What is .docx
 
Your future financial needs will be based on the income you can reas.docx
Your future financial needs will be based on the income you can reas.docxYour future financial needs will be based on the income you can reas.docx
Your future financial needs will be based on the income you can reas.docx
 
Your friend Lydia is having difficulty taking in the informati.docx
Your friend Lydia is having difficulty taking in the informati.docxYour friend Lydia is having difficulty taking in the informati.docx
Your friend Lydia is having difficulty taking in the informati.docx
 

Recently uploaded

Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 

Recently uploaded (20)

Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 

Parking Ticket SimulatorFor this assignment you will design a se.docx

  • 1. 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 bene purchased. · The ParkingTicket Class: The 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 $01 for every additional hour or part of an hour that the car is illegally parked 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 responsibility are: · To know the police office’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 hoe the classes collaborate. Assignment Details Case Study: Sergeant Lou Maynard
  • 2. CJ345-2: Evaluate the implementation of problem-oriented policing within criminal justice entities. Before starting this assignment, please take a few minutes and complete the practice learning activity associated with this outcome. Write a 2–4-page paper (excluding cover page) responding to the following: Read the case study on page 103 in Effective Police Supervision and apply critical thinking to construct persuasive arguments as to what you would you do if you were Sergeant Lou Maynard. Use the questions at the end of the case study to help you construct your paper and be sure to address the following: 1. Describe the motivational issues that exist. 2. The basic need drives for each officer. 3. Assess your management style and how it relates to Theory X. 4. If your level of formal education, or the education of the officers, would be an obstacle. For assistance with this Assignment, refer to Chapter 4 of your text. (PLEASE NOTE: This essay may require outside research.) You may consult the Kaplan Online Library, the internet, the textbook, other course material, and any other outside resources in supporting your task, using proper citations in APA style. Directions for Submitting Your Case Study Write your essay in a Word document and save it in a location and with a name that you will remember. Be sure to include your name, class, and section number in your essay. Submit your Assignment by selecting the Unit 2: Assignment in the Dropbox by the end of Unit 2. Parking Ticket Code/ParkedCar.cppParking Ticket Code/ParkedCar.cpp// Implementation file for the ParkedCar cla ss
  • 3. #include<iostream> #include"ParkedCar.h" usingnamespace std; // Default Constructor ParkedCar::ParkedCar() { make =""; model =""; color =""; licenseNumber =""; minutesParked =0; } // Constructor // Parameters: // mk The car's make. // mod The car's model. // col The car's color. // lic The car's license number. // min The number of minutes parked. ParkedCar::ParkedCar(string mk, string mod, string col, string lic,int min) { make = mk; model = mod; color = col; licenseNumber = lic; minutesParked = min; } // Copy constructor ParkedCar::ParkedCar(constParkedCar&car2) { make = car2.make; model = car2.model;
  • 4. color = car2.color; licenseNumber = car2.licenseNumber; minutesParked = car2.minutesParked; } // print function voidParkedCar::print() { cout <<"Car Information:n"; cout <<"tMake: "<< make << endl; cout <<"tmodel: "<< model << endl; cout <<"tColor: "<< color << endl; cout <<"tLicense Number: "<< licenseNumber << endl; cout <<"tMinutes Parked: "<< minutesParked << endl; } Parking Ticket Code/ParkedCar.h // Specification file for the ParkedCar class #ifndef PARKED_CAR_H #define PARKED_CAR_H #include<string> using namespace std; // ParkedCar class class ParkedCar {
  • 5. private: string make; // The car's make string model; // The car's model string color; // The car's color string licenseNumber; // The car's license number int minutesParked; // Minutes parked public: // Default constructor ParkedCar(); // Constructor ParkedCar(string, string, string, string, int); // Copy constructor ParkedCar(const ParkedCar &); // Mutators
  • 6. void setMake(string m) { make = m; } void setModel(string m) { model = m; } void setColor(string c) { color = c; } void setLicenseNumber(string lic) { licenseNumber = lic; } void setMinutesParked(int m) { minutesParked = m; } // Accessors string getMake() const { return make; }
  • 7. string getModel() const { return model;} string getColor() const { return color; } string getLicenseNumber() const { return licenseNumber; } int getMinutesParked() const { return minutesParked; } // print function void print(); }; #endif
  • 8. Parking Ticket Code/ParkingMeter.h // Specification file for the ParkingMeter class #ifndef PARKING_METER_H #define PARKING_METER_H #include <iostream> using namespace std; // ParkingMeter class class ParkingMeter { private: int minutesPurchased; // Minutes purchased public: // Default constructor ParkingMeter() { minutesPurchased = 0; } // Constructor. The parameter m is
  • 9. // the number of minutes purchased. ParkingMeter(int m) { minutesPurchased = m; } // Mutator void setMinutesPurchased(int m) { minutesPurchased = m; } // Accessor int getMinutesPurchased() const { return minutesPurchased; } // print function void print() { cout << "Meter Information:n"; cout << "tMinutes Purchases: " << minutesPurchased << endl; }
  • 10. }; #endif Parking Ticket Code/ParkingTicket.cppParking Ticket Code/ParkingTicket.cpp// Implementation file for the ParkingTi cket class #include"ParkingTicket.h" #include<iostream> #include<iomanip> usingnamespace std; // Default constructor ParkingTicket::ParkingTicket() { fine =0.0; minutes =0; } // Constructor // Parameters: // aCar - A ParkedCar object. // min - Minutes illegally parked. ParkingTicket::ParkingTicket(ParkedCar aCar,int min) { car = aCar; minutes = min; // Calculate the fine. calculateFine(); } // Copy constructor
  • 11. ParkingTicket::ParkingTicket(constParkingTicket&ticket2) { car = ticket2.car; fine = ticket2.fine; } // calculateFine method // This method calculates the amount of the parking fine. voidParkingTicket::calculateFine() { // Get the time parked in hours. double hours = minutes /60.0; // Get the hours as an int. int hoursAsInt =static_cast<int>(hours); // If there was a portion of an hour, round up. if((hours - hoursAsInt)>0) hoursAsInt++; // Assign the base fine. fine = BASE_FINE; // Add the additional hourly fines. fine +=(hoursAsInt * HOURLY_FINE); } // print function voidParkingTicket::print() { // Print car information. car.print(); // Print ticket information. cout <<"Ticket Information:n"; cout <<"tMinutes in violation: "<< minutes << endl;
  • 12. cout <<"tFine: $ "<< setprecision(2)<< fixed << showpoint << fine << endl; } Parking Ticket Code/ParkingTicket.h // Specification file for the ParkingTicket class #ifndef PARKING_TICKET_H #define PARKING_TICKET_H #include "ParkedCar.h" // Constant for the base fine. const double BASE_FINE = 25.0; // Constant for the additional hourly fine. const double HOURLY_FINE = 10.0; // ParkingTicket class class ParkingTicket { private:
  • 13. ParkedCar car; // The parked car double fine; // The parking fine int minutes; // Minutes illegally parked // calculateFine method // This method calculates the amount of the parking fine. void calculateFine(); public: // Default Constructor ParkingTicket(); // Constructor ParkingTicket(ParkedCar, int); // Copy constructor ParkingTicket(const ParkingTicket &);
  • 14. // Mutators void setCar(ParkedCar c) { car = c; } void setMinutes(int m) { minutes = m; } // Accessors ParkedCar getCar() const { return car; } double getFine() const
  • 15. { return fine; } // print function void print(); }; #endif Parking Ticket Code/PoliceOfficer.cppParking Ticket Code/PoliceOfficer.cpp// Implementation file for the PoliceOffi cer class #include"ParkedCar.h" #include"ParkingMeter.h" #include"ParkingTicket.h" #include"PoliceOfficer.h" #include<iostream> usingnamespace std; // The patrol function looks at the number of // minutes a car has been parked and the number // of minutes purchased. If the minutes parked is // greater than the minutes purchased, a pointer // to a ParkingTicket object is returned. Otherwise // the function returns a nullptr. ParkingTicket*PoliceOfficer::patrol(ParkedCar car,ParkingMete r meter)
  • 16. { // Get the minutes parked over the amount purchased. int illegalMinutes = car.getMinutesParked()- meter.getMinutesPurchased(); // Determine whether the car is illegally parked. if(illegalMinutes >0) { // Yes, it is illegally parked. // Create a ParkingTicket object. ticket =newParkingTicket(car, illegalMinutes); } // Return the ticket, if any. return ticket; } // print function voidPoliceOfficer::print() { cout <<"Police Officer Information:n"; cout <<"tName: "<< name << endl; cout <<"tBadge Number: "<< badgeNumber << endl; } Parking Ticket Code/PoliceOfficer.h // Specification file for the PoliceOfficer class #ifndef POLICE_OFFICER_H #define POLICE_OFFICER_H #include "ParkedCar.h" #include "ParkingMeter.h"
  • 17. #include "ParkingTicket.h" // PoliceOfficer class class PoliceOfficer { private: string name; // Officer's name string badgeNumber; // Badge number ParkingTicket *ticket; // Pointer to a ticket public: // Default constructor PoliceOfficer() { name = ""; badgeNumber = ""; ticket = nullptr; } // Constructor // The parameter n is the officer's name. // The parameter bn is the officer's badge number.
  • 18. PoliceOfficer(string n, string bn) { name = n; badgeNumber = bn; ticket = nullptr; } // Copy constructor PoliceOfficer(const PoliceOfficer &officer2) { name = officer2.name; badgeNumber = officer2.badgeNumber; ticket = new ParkingTicket(*officer2.ticket); } // Mutators void setName(string n) {
  • 19. name = n; } void setBadgeNumber(string b) { badgeNumber = b; } // Accessors string getName() { return name; } string getBadgeNumber() { return badgeNumber; }
  • 20. // patrol function ParkingTicket *patrol(ParkedCar, ParkingMeter); // print function void print(); }; #endif Parking Ticket Code/spc14-14.cppParking Ticket Code/spc14- 14.cpp// Chapter 14, Programming Challenge 14: Parking Ticket Simulator #include<iostream> #include"ParkedCar.h" #include"ParkingMeter.h" #include"ParkingTicket.h" #include"PoliceOfficer.h" usingnamespace std; int main() { // Create a ParkingTicket pointer. If a parking ticket // is issued, this will point to it. ParkingTicket*ticket =nullptr; // Create a ParkedCar object.
  • 21. // The car was parked for 125 minutes. ParkedCar car("Volkswagen","1972","Red","147RHZM",125); // Create a ParkingMeter object. // 60 minutes were purchased. ParkingMeter meter(60); // Create a PoliceOfficer object. PoliceOfficer officer("Joe Friday","4788"); // Let the officer patrol. ticket = officer.patrol(car, meter); if(ticket !=nullptr) { // Display the officer information. officer.print(); // Display the ticket information. ticket->print(); // We're done with the ticket, so delete it. delete ticket; ticket =nullptr; } else cout <<"No crimes were committed.n"; return0; }