Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- using namespace std;
- class Car
- {
- string reportingMark;
- int Carnumber=0;
- string kind="other";
- bool loaded=0;
- string destination="NONE";
- int *ptr;
- public:
- Car(){setUp(reportingMark , Carnumber , kind , loaded , destination);}
- Car(string reportingMark ,int Carnumber ,string kind ,bool loaded ,string destination ){setUp(reportingMark,Carnumber,kind ,loaded , destination);}
- void setUp (string , int , string , bool , string);
- void outPut();
- ~Car();
- }mycar;
- void input (string &reportingMark, int &Carnumber, string &kind, bool &loaded, string &destination);
- int main(int argc, const char * argv[])
- {
- string reportingMark;
- int Carnumber;
- string kind;
- bool loaded;
- string destination="NONE";
- Car car1,car2,car3;
- car1.setUp(reportingMark,Carnumber,kind,loaded,destination);
- car2=car1;
- car3=Car();
- input(reportingMark,Carnumber,kind,loaded,destination);
- car1.outPut();
- car2.outPut();
- car3.outPut();
- return 0;
- }
- void input (string &reportingMark, int &Carnumber, string &kind, bool &loaded, string &destination)
- {
- cout << "What is your reportingMark: "<< endl;
- cin >> reportingMark;
- cout << "What is your carNumber"<< endl;
- cin >> Carnumber;
- cout << "What is your kind of your car?"<<endl;
- while (kind != "business")
- {
- cin >> kind;
- if (kind != "business" && kind != "maintenance" && kind!= "other")
- {
- cout << "Your input is invalid. Please type again "<<endl;
- }
- else
- break;
- }
- cout << "Is your car loaded: "<<endl;
- cout << "If you say yes please type 1. Otherwise please type 0"<<endl;
- cin >>loaded;
- if (loaded == true)
- {
- cout << "What is your destination: "<<endl;
- cin >> destination;
- }
- else if (loaded == false)
- {
- cout << "What is your destination: "<<endl;
- cin >>destination;
- if(destination == "no")
- {
- cout <<"Thank you"<<endl;
- }
- }
- }
- void Car::setUp(string reportingMark, int Carnumber, string kind, bool loaded, string destination)
- {
- mycar.reportingMark=reportingMark;
- mycar.Carnumber=Carnumber;
- mycar.kind=kind;
- mycar.loaded=loaded;
- mycar.destination=destination;
- }
- void Car::outPut()
- {
- cout <<reportingMark<<endl;
- cout <<Carnumber<<endl;
- cout <<kind<<endl;
- cout<<boolalpha<<loaded<<endl;
- cout <<destination<<endl;
- }
- Car::~Car()
- {}
Advertisement
Add Comment
Please, Sign In to add comment