1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <iostream>
#include <iomanip>
#include <string>
#include "Vehicle.h"
using namespace std;
#ifndef VEHICLE_H
#define VEHICLE_H
class Car : public Vehicle{
private:
string modelName;
int sunRoof;
public:
Car(string, double, string, int);
void showVehicle(void);
};
class Truck : public Vehicle{
private:
double capacityTons;
bool autoTrans;
public:
Truck(string, double, double, bool);
void showVehicle(void);
};
#endif
Car::Car(string mfg, double cost, string model, int sun)
:Vehicle(mfg, cost)
{
modelName = model;
int sunRoof = sun;
}
void Car::showVehicle(){
Vehicle::showVehicle();
cout << "Model: " << modelName << endl
<< "Sunroof: " << (sunRoof ? "Yes" : "No") << endl
<< endl;
}
Truck::Truck(string mfg, double cost, double capacity, bool)
:Vehicle(mfg, cost)
{
capacityTons = capacity;
bool autoTrans;
}
void Truck::showVehicle(){
Vehicle::showVehicle();
cout << "Capacity-tons: " << capacityTons << endl
<< "Auto Trans: " << (autoTrans ? "Yes" : "No" << endl
<< endl;
}
|