Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Auto
- {
- int v;
- public:
- Auto()
- {
- v=0;
- }
- Auto(int v1)
- {
- this ->v=v1;
- }
- void set_v(int v1)
- {
- v=v1;
- }
- int get_v()
- {
- return v;
- }
- int beschleunigen(Auto&a)
- {
- int erg;
- if(v<415)
- {
- erg=v+5;
- }
- else
- {
- cout<<"MAX V";
- }
- }
- int bremsen(Auto&a)
- {
- int erg;
- if(v>0)
- {
- erg=v-5;
- }
- else
- {
- cout<<"V unter 0 nicht moeglich";
- }
- }
- };
- int main()
- {
- Auto zweierGolf;
- int eingabe,v;
- cout<<"Wie schnell grad 2erGolf moruk?";
- cin>>v;
- zweierGolf.set_v(v);
- cin>>eingabe;
- if(eingabe=='a')
- {
- v=zweierGolf.beschleunigen(zweierGolf);
- cout<<v;
- }
- if(eingabe=='b')
- {
- v=zweierGolf.bremsen(zweierGolf);
- cout<<v;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement