Make following classes into code. Write Getter and Setters for all members mentioned in brackets of each class, write Copy Constructor, Constructor, and Destructor for each class.
class Car (Make, Model, Type, Passengers, WheelSize, ManualAuto)
class SportsCar (EngineType, Torque, Time_Zeroto60, Acceleration, TopSpeed) inherit SportsCar from Car
class Person (Name, Gender, Age, Nationality, CNIC)
class Driver(Experience, Car, WinCount), inherit Driver from Person
#include <iostream>
using namespace std;
class Car{
protected:
//class Car (Make, Model, Type, Passengers, WheelSize, ManualAuto)
string Make,Model,Type,Passengers,WheelSize,ManualAuto;
public:
void setMake(string m){
Make = m;
}
string getMake(){
return Make;
}
void setModel(string mod){
Model = mod;
}
string getModel(){
return Model;
}
void setType(string t){
Type = t;
}
string getType(){
return Type;
}
void setPassengers(string p){
Passengers = p;
}
string getPassengers(){
return Passengers;
}
void setWheelSize(string w){
WheelSize = w;
}
string getWheelSize(){
return WheelSize;
}
void setManualAuto(string ma){
ManualAuto = ma;
}
string getManualAuto(){
return ManualAuto;
}
Car(Car &obj) {
//leng = obj.length;
}
Car(){
}
~Car(){
}
};
//class SportsCar (EngineType, Torque, Time_Zeroto60, Acceleration, TopSpeed)
class SportsCar:public Car{
private:
string EngineType, Torque, Time_Zeroto60, Acceleration, TopSpeed;
public:
void setEngineType(string e){
EngineType = e;
}
string getEngineType(){
return EngineType;
}
void setTorque(string to){
Torque = to;
}
string getTorque(){
return Torque;
}
void setTime_Zeroto60(string tm){
Time_Zeroto60 = tm;
}
string getTime_Zeroto60(){
return Time_Zeroto60;
}
void setAcceleration(string a){
Acceleration=a;
}
string getAcceleration(){
return Acceleration;
}
void setTopSpeed(string ts){
TopSpeed=ts;
}
string getTopSpeed(){
return TopSpeed;
}
SportsCar(SportsCar &obj) {
}
SportsCar(){
}
~SportsCar(){
}
};
//class Person (Name, Gender, Age, Nationality, CNIC)
class Person{
protected:
string Name, Gender, Age, Nationality, CNIC;
public:
void setName(string n){
Name = n;
}
string getName(){
return Name;
}
void setGender(string g){
Gender = g;
}
string getGender(){
return Gender;
}
void setAge(string ag){
Age = ag;
}
string getMake(){
return Age;
}
void setNationality(string nt){
Nationality= nt;
}
string getNationality(){
return Nationality;
}
void setCNIC(string c){
CNIC = c;
}
string getCNIC(){
return CNIC;
}
Person(SportsCar &obj) {
}
Person(){
}
~Person(){
}
};
//class Driver(Experience, Car, WinCount)
class Driver:public Person{
private:
string Experience, Car, WinCount;
public:
void setExperience(string ex){
Experience = ex;
}
string getExperience(){
return Experience;
}
void setCar(string ca){
Car = ca;
}
string getCar(){
return Car;
}
void setWinCount(string wc){
WinCount = wc;
}
string getWinCount(){
return WinCount;
}
Driver(SportsCar &obj) {
}
Driver(){
}
~Driver(){
}
};
int main()
{
return 0;
}
Comments
Leave a comment