Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. class Automobil
  6. {
  7.     int v;
  8. public:
  9.     Automobil()
  10.     {
  11.         v = 300;
  12.     }
  13.  
  14.     Automobil(int v)
  15.     {
  16.         this ->v = v;
  17.     }
  18.  
  19.     int get_v()
  20.     {
  21.         return v;
  22.     }
  23.  
  24.     void set_v(int v)
  25.     {
  26.         this ->v = v;
  27.     }
  28.  
  29.     int beschleunigen(Automobil&a)
  30.     {
  31.         int erg;
  32.         erg = v+5;
  33.         return erg;
  34.     }
  35.  
  36.     int bremsen(Automobil&b)
  37.     {
  38.         int erg;
  39.  
  40.         erg = v-5;
  41.         return erg;
  42.     }
  43. };
  44.  
  45. int main()
  46. {
  47.     Automobil audi;
  48.     int eingabe,v;
  49.     cout<<"Wie schnell fahrt ihr Auto ? ";
  50.     cin>>v;
  51.     audi.set_v(v);
  52.     cout<<"Bremsen[2] oder Beschleunigen[1]?";
  53.     cin>>eingabe;
  54.     if(eingabe == 1)
  55.     {
  56.          v = audi.beschleunigen(audi);
  57.         cout<<v;
  58.     }
  59.     if(eingabe == 2)
  60.     {
  61.         v = audi.bremsen(audi);
  62.         cout<<v;
  63.     }
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement