Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment you will design a set of classes that work together to simul

ID: 3690237 • Letter: F

Question

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
Write a program that demonstrates how these classes collaborate.

Explanation / Answer

class parkingCar{

    public :

        //decalring variables as given condition

        int num_minutes;

        String carsMake;

        String model;

        String color;

        String licenseNum;      

};

//inherits the parking class into parkingMeter

class parkingMeter:public parkingCar{

    public:

        //calculating number of Minutes

        void numberofMinutes(int num_minutes){

            this.num_minutes = num_minutes;

    }

};

//inheriting the parkingCar class here

class parkingTicket:public parkingCar{

    public:

        //access the car e carsMake

        void parkingcarsMake(){

            cout<<"Enter carsMake"<<endl;

            cin>>carsMake;

        }

        //access the car model

        void parkingcarModel(){

            cout<<"Enter car model"<<endl;

            cin>>carModel;

        }

        //access the carModel

        void parkingcarColor(){

            cout<<"Enter color"<<endl;

            cin>>color;

        }

        //access the licensenumber

        void parkingcarlic_number(){

            cout<<"Enter car license number"<<endl;

            cin>>licenseNum;

        }

        //total report of car

        void reportofParkingcar(){

            cout<<"car details"<<endl;

            cout<<carsMake<<endl;

            cout<<carModel<<endl;

            cout<<color<<endl;

            cout<<licenseNum<<endl;

           

        }

};

class policeOfficer:{

    //decalration of officername, badge number as String data type

    public:

        String officerName;

        String badgeNumber;

        void officerName(){

            cout<<"Enter officerName";

            cin>>officerName;

        }

        void badgeNumber(){

            cout<<"Enter badge Number";

            cin>>badgeNumber;

        }

        //parking car object

        parkingCar pCar;

        //parking meter object

        parkingMeter pMeter;

        pMeter.numberofMinutes(100);   

};

//accessing the classes here

int main(){

    //creating the object of policeOfficer

    policeOfficer officer;

    officer.officerName();

    officer.badgeNumber();

    return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote