Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. class Car
  7. {
  8. private:
  9. int productYear;
  10. char regNumber[16];
  11. char brandAndModel[31];
  12. char owner[31];
  13.  
  14. public:
  15. //Deafault Constructor
  16. Car();
  17.  
  18. //Constructor
  19. Car(int = 0, char* = '\0', char* = '\0', char* = '\0');
  20.  
  21. //Copy Constructor
  22.  
  23. //Operator=
  24.  
  25. //Destructor
  26.  
  27. //Getters
  28. int getProductYear() const;
  29. char& getRegNumber() const;
  30. char& getBrandAndModel() const;
  31. char& getOwner() const;
  32.  
  33. //Setters
  34. void changeProductYear(int);
  35. void changeRegNumber(char*);
  36. void changeBrandAndModel(char*);
  37. void changeOwner(char*);
  38.  
  39. //Others
  40. void print();
  41.  
  42. void comparator(const Car&, const Car&);
  43. };
  44.  
  45. Car::Car()
  46. {
  47. productYear = 0;
  48. strcpy(regNumber, "None");
  49. strcpy(brandAndModel, "None");
  50. strcpy(owner, "None");
  51. }
  52.  
  53. Car::Car(int _year, char* _regnumber, char* _model, char* _owner)
  54. : productYear(_year)
  55. {
  56. strcpy(regNumber, _regnumber);
  57. strcpy(brandAndModel, _model);
  58. strcpy(owner, _owner);
  59. }
  60.  
  61. int Car::getProductYear() const
  62. {
  63. return productYear;
  64. }
  65.  
  66.  
  67.  
  68. void Car::print()
  69. {
  70. cout << "Year of product: " << productYear << endl;
  71.  
  72. cout << "Registartion number: " << regNumber << endl;
  73.  
  74. cout << "Brand and model: " << brandAndModel << endl;
  75.  
  76. cout << "Owner: " << owner << endl;
  77. }
  78.  
  79. int main() {
  80. Car car1(1999, "OB7408BH", "Volkswagen", "Radoslav");
  81. car1.print();
  82.  
  83. Car car11();
  84.  
  85. cout << car11.getProductYear() << endl;
  86.  
  87.  
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement