Question
In C++ Write a program that creates a Bus class that includes a bus ID number, number of seats, driver name, and current speed. Create
In C++
Write a program that creates a Bus class that includes a bus ID number, number of seats, driver name, and current speed. Create a default constructor without any parameters that initializes the value of ID number, number of seats, and driver name. Create another constructor with three parameters of bus id number, number of seats, and driver name. Car speed should always be initialized as 0.
The program will also include the member functions to perform the various operations: modify, set, and display bus information (Bus id, number of seats, driver name, and current speed).
For example:
- Set the bus id number
- Set the number of seats
- Set of driver number
----------------------------------------------------
- Return the bus id number by using get method
- Return the number of seats
- Return of driver number
- Return the current speed
-----------------------
Member function to display the bus information
- busInformation()
Also write two member functions, Accelerate() and Brake(). Whenever Accelerate() is called, increase the speed by 5 (cannot exceed 50), and whenever Brake() is called, decrease the speed by 5 (cannot be negative). Write a program that declares several Bus objects and demonstrates that all the functions work correctly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started