- Back to Home »
- Solutions »
- CS201 Assignment no 3 Fall 2012 Full Solution
Posted by : Anonymous
Tuesday, 15 January 2013
#include<iostream.h>
#include<conio.h>
using namespace std;
class Vehicle{
public:
void display();
void setcompany(string a);
void setmodel(string a);
void setenginecapacity(int a);
void setyear(int a);
void getinput();
string getcompany();
string getmodel();
int getenginecapacity();
int getyear();
Vehicle();
Vehicle(string,string,int,int);
~Vehicle();
private:
string company;
string model;
int year;
int enginecapacity;
string company2;
string model2;
int year2;
int enginecapacity2;
int number,S,C;
};
Vehicle::Vehicle()
{
company=S;
model=C;
year=2011;
enginecapacity=1500;
}
void Vehicle::getinput()
{
cout<<"Enter the number of vehicle :";
cin>>number;
cout<<"Vehicle1"<<endl;
cout<<"Enter the name of vehicle maker company :";
cin>>company;
cout<<"Enter the vehicle model :";
cin>>model;
cout<<"Enter year of registration :";
cin>>year;
cout<<"Enter the engine capacity of the vehicle :";
cin>>enginecapacity;
cout<<endl;
cout<<"Vehicle2"<<endl;
cout<<"Enter the name of vehicle maker company :";
cin>>company2;
cout<<"Enter the vehicle model :";
cin>>model2;
cout<<"Enter year of registration :";
cin>>year2;
cout<<"Enter the engine capacity of the vehicle :";
cin>>enginecapacity2;
cout<<endl;
}
Vehicle::~Vehicle()
{
cout<<"object deleted"<<endl;
}
void Vehicle::display()
{
cout<<"vehicle 1"<<endl<<"Enter the vehicle maker company :"<<getcompany()<<endl<<"Enter the vehicle model :"<<getmodel()<<endl<<"Enter year of registration :"<<getyear()<<endl<<"Enter the engine capacity of the vehicle :"<<getenginecapacity();
cout<<endl;
cout<<"vehicle 2"<<endl<<"Enter the vehicle maker company :"<<company2<<endl<<"Enter the vehicle model :"<<model2<<endl<<"Enter year of registration :"<<year2<<endl<<"Enter the engine capacity of the vehicle :"<<enginecapacity2;
cout<<endl;
}
void Vehicle::setcompany(string k)
{
company=k;
}
void Vehicle::setmodel(string a)
{
model=a;
}
void Vehicle::setyear(int a)
{
year=a;
}
void Vehicle::setenginecapacity(int a)
{
enginecapacity=a;
}
string Vehicle::getcompany()
{
return company;
}
int Vehicle::getenginecapacity()
{
return enginecapacity;
}
string Vehicle::getmodel()
{
return model;
}
int Vehicle::getyear()
{
return year;
}
int main()
{
Vehicle raousman1;
raousman1.getinput();
raousman1.display();
raousman1.~Vehicle();
getch();
}