SHARE
TWEET

Untitled

a guest Oct 16th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     void setYear();
  13.     int getYear();
  14.    
  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.     Car Suv("Toyota", 2019, 'A');
  29.     Car Suv1("Honda", 2019, 'A');
  30.     Car year1;
  31.     cout << "Enter your Car Year" << endl;
  32.     cin >> inputYear;
  33.     year1.compare(inputYear);
  34.    
  35.     return(0);
  36. }
  37.  
  38. Car::Car(string brandname, int modelyear, char initGrade)
  39. {
  40.  
  41.     brand = brandname;
  42.     year = modelyear;
  43.     grade = initGrade;
  44.     cout << "Car 1: " << endl;
  45.     cout << "Brand: " << brand << endl;
  46.     cout << "Year: " << year << endl;
  47.     cout << "Car 1: " << endl;
  48.     cout << "Grade: " << grade << endl;
  49. }
  50. void Car::compare(int inYear)
  51. {
  52.     if (year < inYear)
  53.         cout << "Swaping is allowed" << endl;
  54.     else
  55.         cout << "Swaping is NOT allowed, your car should be newer than 2010." << endl;
  56.  
  57. };
  58.  
  59. int Car::getYear()
  60. {
  61.     cout << "Year is" << year << endl;
  62.     return year;
  63. }
  64. void Car::setYear()
  65. {
  66.     year = 2005;
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top