Guest User

Untitled

a guest
May 27th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. class Vehicle {
  7.  
  8. private:
  9. int fuel;
  10. int price;
  11. char color[20];
  12. char brand[20];
  13. public:
  14. void setFuel(int someFuel){
  15.  
  16. fuel = someFuel;
  17. }
  18.  
  19. void setPrice(int thePrice){
  20.  
  21. price = thePrice;
  22. }
  23.  
  24. void setColor(char theColor[]){
  25.  
  26. strcpy(this->color, theColor );
  27. }
  28.  
  29. void setBrand(char thebrand[]){
  30.  
  31. strcpy(this->brand, thebrand);
  32. }
  33.  
  34. int getFuel(){
  35. return fuel;
  36. }
  37.  
  38. int getPrice(){
  39. return price;
  40. }
  41.  
  42. char* getColor(){
  43. return color;
  44. }
  45. char* getBrand(){
  46. return brand;
  47. }
  48. };
  49.  
  50. int main (int argc, char * const argv[]) {
  51. // insert code here...
  52.  
  53. Vehicle car;
  54. Vehicle motorCycle;
  55.  
  56. car.setFuel(70);
  57. motorCycle.setFuel(20);
  58. car.setPrice(1500000);
  59. motorCycle.setPrice(400000);
  60. car.setColor("Blue");
  61. motorCycle.setColor("Red");
  62. car.setBrand("Honda");
  63. motorCycle.setBrand("Yamaha");
  64.  
  65. cout << "== Car Details == " << endl;
  66. cout << "Car MAX Fuel is " << car.getFuel() << endl;
  67. cout << "Car Price is RP." << car.getPrice() << endl;
  68. cout << "Car Color is " << car.getColor() << endl ;
  69. cout << "Car Brand is " << car.getBrand() << endl << endl;
  70.  
  71. cout << "== MotorCycle Details == " << endl;
  72. cout << "MotorCycle MAX Fuel is " << motorCycle.getFuel() << endl;
  73. cout << "MotorCycle Price is RP." << motorCycle.getPrice() << endl;
  74. cout << "MotorCycle Color is " << motorCycle.getColor() << endl ;
  75. cout << "MotorCycle Brand is " << motorCycle.getBrand() << endl << endl;
  76.  
  77.  
  78.  
  79. return 0;
  80. }
Add Comment
Please, Sign In to add comment