Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- class Automobil
- {
- int v;
- public:
- Automobil()
- {
- v = 300;
- }
- Automobil(int v)
- {
- this ->v = v;
- }
- int get_v()
- {
- return v;
- }
- void set_v(int v)
- {
- this ->v = v;
- }
- int beschleunigen(Automobil&a)
- {
- int erg;
- erg = v+5;
- return erg;
- }
- int bremsen(Automobil&b)
- {
- int erg;
- erg = v-5;
- return erg;
- }
- };
- int main()
- {
- Automobil audi;
- int eingabe,v;
- cout<<"Wie schnell fahrt ihr Auto ? ";
- cin>>v;
- audi.set_v(v);
- cout<<"Bremsen[2] oder Beschleunigen[1]?";
- cin>>eingabe;
- if(eingabe == 1)
- {
- v = audi.beschleunigen(audi);
- cout<<v;
- }
- if(eingabe == 2)
- {
- v = audi.bremsen(audi);
- cout<<v;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement