Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. class Auto
  6. {
  7. int v;
  8.  
  9. public:
  10.  
  11. Auto()
  12. {
  13. v=0;
  14.  
  15. }
  16. Auto(int v1)
  17. {
  18. this ->v=v1;
  19. }
  20. void set_v(int v1)
  21. {
  22. v=v1;
  23. }
  24.  
  25.  
  26. int get_v()
  27. {
  28. return v;
  29. }
  30. int beschleunigen(Auto&a)
  31. {
  32. int erg;
  33. if(v<415)
  34. {
  35. erg=v+5;
  36. }
  37. else
  38. {
  39. cout<<"MAX V";
  40. }
  41. }
  42. int bremsen(Auto&a)
  43. {
  44. int erg;
  45. if(v>0)
  46. {
  47. erg=v-5;
  48. }
  49. else
  50. {
  51. cout<<"V unter 0 nicht moeglich";
  52. }
  53. }
  54.  
  55.  
  56.  
  57. };
  58.  
  59. int main()
  60. {
  61. Auto zweierGolf;
  62. int eingabe,v;
  63. cout<<"Wie schnell grad 2erGolf moruk?";
  64. cin>>v;
  65. zweierGolf.set_v(v);
  66. cin>>eingabe;
  67. if(eingabe=='a')
  68. {
  69. v=zweierGolf.beschleunigen(zweierGolf);
  70. cout<<v;
  71. }
  72. if(eingabe=='b')
  73. {
  74. v=zweierGolf.bremsen(zweierGolf);
  75. cout<<v;
  76. }
  77.  
  78.  
  79.  
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement