You are on page 1of 5

Car Specifications

============================================
#include <iostream.h>
#include <string.h>
#include <conio.h>

/////////////////// Brake Class ///////////////////

class disk_Brakes
{
private:

int location; // front,back


int total_no; // 2 or 4

public:

disk_Brakes(int loc, int tnum)


{
location = loc;
total_no= total_no;
}

int getLocation()
{
return location;
}
int getNumber()
{
return total_no;
}
};

class IBS //Integrated Brakes System


{
private:

int value; // 16 value


int isThere; // 1 for fitted, 0 for not fitted

public:

IBS(int v, int is)


{
value = v;
isThere = is;
}

int getValue()
{
return value;
}

int getIsThere()
{

return isThere;

}
};

class Brake
{
private:
char quality[15]; // Good , Normal
IBS I;
disk_Brakes D;
public:
Brake(char* q, int loc, int tnum, int v, int is): D(loc,tnum),I(v,is)
{
strcpy(quality,q);
}
void printBrakeSpecification()
{
cout<< "\n\nQuality of brakes
(Good,Normal)\t\t\t\t\t\t" << quality;
cout<< "\nLocation of disk brakes(0-front, 1- front &
back)\t\t\t" << D.getLocation();
cout<< "\nTotal number of disk brakes\t\t\t\t\t\t" <<
D.getNumber();
cout<< "\nIs there IBS brakes fitted\t(1 for fitted, 0 for not
fitted)\t" << I.getIsThere();
cout<< "\nIf fitted then what is the value(eg 16
value)\t\t\t\t" << I.getValue();
}

};
/*********************************/

/* ******************* ENGINE CLASS


******************* */
class gearBox
{
private:
int isAuto; // automatic or manual
public:
gearBox(int a)
{
isAuto = a;
}
int getIsAuto()
{
return isAuto;
}
};

class cylinder
{
private:
int capacity;
public:
cylinder(int c)
{
capacity = c;
}
int getCapacity()
{
return capacity;
}
};

class generator
{
private:
int power;
public:
generator(int p)
{
power = p;
}
int getPower()
{
return power;
}
};

class Engine
{
private:
int power; // cc
gearBox Gb;
cylinder Cy;
generator Gn;

public:
Engine(int pow,int a, int c, int p ):Gb(a),Cy(c),Gn(p)
{
power = pow;
}
int getPower()
{
return power;
}
void printEngineSpecifications()
{
cout<< "\n\nThe power of the engine is\t\t\t\t\t\t" <<
power;
cout<< "\nIs it manual transmission(0 for No & 1 for
Yes)\t\t\t\t" << Gb.getIsAuto();
cout<< "\nCapacity of cylinder in KGs(eg 6 kg)\t\t\t\t\t"
<< Cy.getCapacity();
cout<< "\nThe power of generator is (eg 500
btu`s)\t\t\t\t" << Gn.getPower();
}
};

/****************************/

/***************************** CAR CLASS


*******************************/
class car
{
private:
char brandName[20];
int model;
Brake B;
Engine E;

public:
car(char* Bn,int m,char* q, int loc, int tnum, int v, int is,int
pow,int a, int c, int p):B(q,loc,tnum,v,is),E(pow,a,c,p )
{
strcpy(brandName,Bn);
model = m;
}

void printCarSpecification()
{
cout<< "\n\nCar Name\t\t\t\t\t\t\t\t"<< brandName;
cout<< "\nCar Model\t\t\t\t\t\t\t\t" << model;
E.printEngineSpecifications();
B.printBrakeSpecification();
}
};

void main()
{
car a("mehran",2008,"good",1,4,16,1,1600,1,6,500);
a.printCarSpecification();
getch();
}

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006