Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. class Car
  7. {
  8. public:
  9. Car (string brandname, int modelyear, char initGrade);
  10. Car()
  11. {};
  12.  
  13. int getYear();
  14. void setYear();
  15.  
  16. void compare(int inYear);
  17.  
  18. private:
  19. string brand;
  20. int year = 2010;
  21. char grade;
  22. };
  23.  
  24. int main()
  25. {
  26. int inputYear;
  27. cout << "The Listed cars are available to SWAP" << endl;
  28. cout << "Car 1: " << endl;
  29. Car Suv("Toyota", 2019, 'A');
  30. cout << "Car 2: " << endl;
  31. Car Suv1("Honda", 2019, 'A');
  32. Car year1;
  33. cout << "Enter your Car Year that you would like to Swap" << endl;
  34. cin >> inputYear;
  35. year1.compare(inputYear);
  36.  
  37. return(0);
  38. }
  39.  
  40. Car::Car(string brandname, int modelyear, char initGrade)
  41. {
  42.  
  43. brand = brandname;
  44. year = modelyear;
  45. grade = initGrade;
  46.  
  47. cout << "Brand: " << brand << endl;
  48. cout << "Year: " << year << endl;
  49.  
  50. cout << "Grade: " << grade << endl;
  51. }
  52. void Car::compare(int inYear)
  53. {
  54. if (year < inYear)
  55. cout << "Swaping is allowed" << endl;
  56. else
  57. cout << "Swaping is NOT allowed, your car should be newer than 2010." << endl;
  58.  
  59. };
  60.  
  61. int Car::getYear()
  62. {
  63. cout << "Year is" << year << endl;
  64. return year;
  65. }
  66. void Car::setYear()
  67. {
  68. int choiceYear = 2005;
  69. year = choiceYear;
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement