Advertisement
SUBANGKAR

main() of Automobile

Sep 29th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <conio.h>
  2. #include <Windows.h>
  3. #include <ctime>
  4. #include <iostream>
  5.  
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11.     SUV bus;
  12.  
  13.     double x=0, y=0;
  14.     char c;
  15.  
  16.     while (1)
  17.     {
  18.         bus.GetPosition(x, y);
  19.         printf("%15s : %s\n","Vehicle Type", bus.GetType());
  20.         printf("%15s : ( %.9g , %.9g )\n", "Position (X,Y)", x, y);
  21.         printf("%15s : %.5f\n","Remaining Fuel", bus.GetFuel());
  22.         printf("%15s : %.5g\n","Velocity", bus.GetSpeed());
  23. //      printf("%15s : %d\n", "Gear Position",bus.GetGearPosition());
  24.         bus.GetDirection(x, y);
  25.         printf("%15s : x=%.5f y=%.5f\n","Direction", x, y);
  26.         printf("%15s : %-3d\n","Angle ^ X-axis", bus.getTotalTurnAngle());
  27.  
  28.         if (_kbhit())
  29.         {
  30.             c = _getch();
  31.             cout << ">>" << c << endl;
  32.             switch (c) {
  33.             case 'a':
  34.                 bus.TurnLeft();
  35.                 break;
  36.             case 'd':
  37.                 bus.TurnRight();
  38.                 break;
  39.             case 'g':
  40.             //  bus.ShiftGearUp();
  41.                 break;
  42.             case 'x':
  43.             //  bus.ShiftGearDown();
  44.                 break;
  45.             case 'w':
  46.                 bus.IncreaseSpeed();
  47.                 break;
  48.             case 's':
  49.                 bus.DecreaseSpeed();
  50.                 break;
  51.             }
  52.         }
  53.  
  54.         bus.Move();
  55.         Sleep(300); // Delay Korar jonno
  56.         system("CLS");
  57.     }
  58.  
  59.     return 0;
  60. }
  61.  
  62. // With <3 from Sazan
  63. // & Edited by Subangkar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement