Navigation Bar

Program of class car using setter, getter, destructor in OOP



#include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;
class car
{
                public :
                int model;
                char company;
                char color;
                int price;
                void get()
                {
                cout<<"Enter car model year: ";
                cin>>model;
                cout<<"Enter company name: ";
                cin>>company;
                cout<<"Enter color: ";
                cin>>color;
                cout<<"Enter Price: ";
                cin>>price;
                }
                void set(int mod,char comp, char clr,int pr)
                {
                                model = mod;
                                company = comp;
                                color = clr;
                                price = pr;                           
                }
void show()
                {
                                cout<<"Car Model = "<<model<<endl;
                                cout<<"Car manufacture = "<<company<<endl;
                                cout<<"Car color = "<<color<<endl;
                                cout <<"Car = "<<price<<endl<<endl;
                }
                void accelerator()
                {
                                cout<<"Car is accelerating"<<endl;
                }
                void start()
                {
                                cout<<"Car is starting"<<endl;
                }
                int getprice()
                {
                                return price;
                }
                ~car()
                {
                                cout<<"\n\tPlease lock the Car"<<endl;
                }
};
int main()
{
                car s, s1;
                s.get();
                s1.set(2016,'T','R',255000);
                cout<<"\tSpecifications of both Cars"<<endl;
                s.show();
                s1.show();
                cout<<"\tHigh Price Cars is"<<endl;
                if(s.getprice()>s1.getprice())
                                s.show();
                else
                 s1.show();
                 s.start();
                s.accelerator();
                getch();
}

Output

No comments:

Post a Comment