Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ This assignment requires several classes which interact with each other. Two class aggregations are formed. The program will simulate a police officers beat where

C++

This assignment requires several classes which interact with each other. Two class aggregations are formed. The program will simulate a police officers beat where the officer is giving out tickets for parked cars whose meters have expired.

The following are the list of classes required for the program and the interaction between them. You must include both a header file and an implementation file for each class.

Car class (include Car.h and Car.cpp) Contains the information about a car.

  • Contains data members for the following
    • String make
    • String model
    • String color
    • String license number
  • Default constructor
  • Mutators and accessors for all data members
  • Overload the << operator.

ParkedCar class (include ParkedCar.cpp ParkedCar.h) simulates a parked car. Knows which type of car is parked and the number of minutes that the car has been parked.

  • Contains data members for the following
    • Car (instance of the class above)
    • Integer minutes parked.
  • Default constructor
  • Constructor (5 parameters)
  • Copy constructor
  • Mutators and accessors for data members other than Car
  • Overload the << operator

ParkingMeter class (include ParkingMeter.h and ParkingMeter.cpp) simulates a parking meter. Should know the number of minutes of parking time that has been purchased.

  • Contains data members for the following
    • Integer minutes purchased to park
  • Default constructor
  • Constructor (1 parameter)
  • Mutator and accessor for data member
  • Overload the << operator

ParkingTicket class (include ParkingTicket.h and ParkingTicket.cpp) simulates a parking ticket.

  • Responsibilites are:
    • Report the car information for illegally parked car
    • Report the amount of 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
  • Contains data members for the following
    • ParkedCar instance of class above
    • Double fine the calculated parking fine
    • Int minutes the minutes illegally parked
  • Default constructor
  • Constructor (2 parameter ParkedCar and integer)
  • Mutator and accessor for all data member
  • Overload the << operator
  • Private method to calculate the fine

PoliceOfficer class (include PoliceOffier.h and PoliceOfficer.cpp)

  • Responsibilites are:
    • Know the name and badge number of the officer
    • Examine a ParkedCar object and a ParkingMeter object and determine whether the cars time has expired
    • Issue a parking ticket (create a ParkingTicket) if the cars time has expired
  • Contains data members for the following
    • ParkingTicket pointer to an instance of class above
    • String name of officer
    • String badge number of officer
  • Default constructor (correctly initialize all data members)
  • Constructor (2 parameter name and badge number, all data member initialized correctly)
  • Mutator and accessor for all data member (not ParkingTicket)
  • Overload the << operator
  • Method called patrol which issues (returns) ParkingTicket as a pointer. Has two parameters ParkedCar and ParkingMeter.

Main should completely test the interactions of all the classes and all of the method required. The main below shows and example of how the program should work. This is not a complete main for the program. The program should have a car that is not given a ticket, one with a ticket within an hour and another for more than one hour.

#include #include "ParkedCar.h" #include "ParkingMeter.h" #include "ParkingTicket.h" #include "PoliceOfficer.h" using namespace std; int main() { ParkingTicket *ticket = nullptr; ParkedCar car("Volkswagen", "1972", "Red", "147RHZM", 125); ParkingMeter meter(60); PoliceOfficer officer("Joe Friday", "4788"); ticket = officer.patrol(car, meter); if (ticket != nullptr) { cout << officer; cout << *ticket; delete ticket; ticket = nullptr; } else cout << "No crimes were committed. "; return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions