Guest User

Untitled

a guest
Oct 31st, 2016
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. class Car
  7. {
  8. string reportingMark;
  9. int Carnumber=0;
  10. string kind="other";
  11. bool loaded=0;
  12. string destination="NONE";
  13. int *ptr;
  14. public:
  15. Car(){setUp(reportingMark , Carnumber , kind , loaded , destination);}
  16. Car(string reportingMark ,int Carnumber ,string kind ,bool loaded ,string destination ){setUp(reportingMark,Carnumber,kind ,loaded , destination);}
  17. void setUp (string , int , string , bool , string);
  18. void outPut();
  19. ~Car();
  20. }mycar;
  21.  
  22. void input (string &reportingMark, int &Carnumber, string &kind, bool &loaded, string &destination);
  23.  
  24. int main(int argc, const char * argv[])
  25. {
  26. string reportingMark;
  27. int Carnumber;
  28. string kind;
  29. bool loaded;
  30. string destination="NONE";
  31. Car car1,car2,car3;
  32. car1.setUp(reportingMark,Carnumber,kind,loaded,destination);
  33. car2=car1;
  34. car3=Car();
  35. input(reportingMark,Carnumber,kind,loaded,destination);
  36. car1.outPut();
  37. car2.outPut();
  38. car3.outPut();
  39.  
  40. return 0;
  41. }
  42. void input (string &reportingMark, int &Carnumber, string &kind, bool &loaded, string &destination)
  43. {
  44. cout << "What is your reportingMark: "<< endl;
  45. cin >> reportingMark;
  46. cout << "What is your carNumber"<< endl;
  47. cin >> Carnumber;
  48. cout << "What is your kind of your car?"<<endl;
  49. while (kind != "business")
  50. {
  51. cin >> kind;
  52.  
  53. if (kind != "business" && kind != "maintenance" && kind!= "other")
  54. {
  55. cout << "Your input is invalid. Please type again "<<endl;
  56. }
  57. else
  58. break;
  59. }
  60.  
  61. cout << "Is your car loaded: "<<endl;
  62. cout << "If you say yes please type 1. Otherwise please type 0"<<endl;
  63. cin >>loaded;
  64. if (loaded == true)
  65.  
  66. {
  67. cout << "What is your destination: "<<endl;
  68. cin >> destination;
  69. }
  70. else if (loaded == false)
  71. {
  72. cout << "What is your destination: "<<endl;
  73. cin >>destination;
  74. if(destination == "no")
  75. {
  76. cout <<"Thank you"<<endl;
  77. }
  78. }
  79. }
  80.  
  81.  
  82. void Car::setUp(string reportingMark, int Carnumber, string kind, bool loaded, string destination)
  83. {
  84. mycar.reportingMark=reportingMark;
  85. mycar.Carnumber=Carnumber;
  86. mycar.kind=kind;
  87. mycar.loaded=loaded;
  88. mycar.destination=destination;
  89.  
  90. }
  91.  
  92. void Car::outPut()
  93. {
  94. cout <<reportingMark<<endl;
  95. cout <<Carnumber<<endl;
  96. cout <<kind<<endl;
  97. cout<<boolalpha<<loaded<<endl;
  98. cout <<destination<<endl;
  99. }
  100.  
  101. Car::~Car()
  102. {}
Advertisement
Add Comment
Please, Sign In to add comment