I'm having issues doing this assignment. I'm not really sure what's wrong, so hopefully someone can help
HERE'S THE CODE
#include<iostream>
using namespace std;
class Vehicle
{
private:
int Age;
protected:
float Price;
public:
Vehicle();
~Vehicle();
void setAge(int i)
{
Age = i;
};
void setPrice(float i)
{
Price = i;
};
int getAge()const;
float getPrice()const;
};
Vehicle::Vehicle()
{
Age = 0;
Price = 0;
}
Vehicle::~Vehicle()
{
Age = 0;
Price = 0;
}
int Vehicle::getAge() const
{
return Age;
}
float Vehicle::getPrice() const
{
return Price;
}
class Car:
public Vehicle
{
public:
bool RaceCarStatus;
Car();
Car(const Car ©Car);
~Car();
void setRaceCarStatus(bool);
bool getRaceCarStatus()const;
};
Car::Car()
{
RaceCarStatus = false;
}
Car::~Car()
{
int i;
i = 0;
}
void Car::setRaceCarStatus(bool)
{
RaceCarStatus = false;
}
bool Car::getRaceCarStatus() const
{
return RaceCarStatus;
}
class Truck:
public Vehicle
{
bool DieselTypeStatus;
Truck();
void Truck(bool);
~Truck();
void DieselTypeStatus(bool);
bool getDieselTypeStatus()const;
};
Truck::Truck()
{
DieselTypeStatus = false;
}
Truck::~Truck()
{
int i;
i = 0;
}
void Truck::setDieselTypeStatus(bool)
{
setDieselTypeStatus = false;
}
bool Truck::setDieselTypeStatus() const
{
return setDieselTypeStatus;
}
int main()
{
Vehicle x;
cout << "Initial value for x: " << endl;
cout << "Age = " << x.getAge() << "Price = " << x.getPrice() << endl;
x.setAge(40);
x.setPrice(20000);
cout << "Modified value for x: " << endl;
cout << "Age = " << x.getAge() << "Price = " << x.getPrice() << endl;
cout << endl;
Car y;
cout << "Initial value for y: " << endl;
cout << "Age = " << y.getAge() << "Price = " << y.getPrice() << endl;
y.setAge(5);
y.setPrice(40000);
cout << "Modified value for y: " << endl;
cout << "Age = " << y.getAge() << "Price = " << y.getPrice() << endl;
cout << "Initial race car status for y: " << y.getRaceCarStatus() << endl;
y.setRaceCarStatus(1);
cout << "Modified race car status for y " << y.getRaceCarStatus() << endl;
cout << endl;
Truck z;
cout << "Initial value for z: " << endl;
cout << "Age = " << z.getAge() << "Price = " << z.getPrice() << endl;
z.setAge(25);
z.setPrice(30000);
cout << "Modified value for x: " << endl;
cout << "Age = " << z.getAge() << "Price = " << z.getPrice() << endl;
return 0;
}
HERE'S THE INSTRUCTIONS
We need to use class truck and car as inheriting attributes from vehicle.