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. Subm.
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
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; }
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)
{
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;
}