Guest User

Untitled

a guest
Jan 10th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1.  
  2. import java.io.*;
  3. import static java.lang.System.*;
  4. import java.util.Scanner;
  5.  
  6. public class student_runner_Vehicle {
  7. public static void main(String str[]) throws IOException {
  8. Vehicle v1 = new Vehicle(17);
  9.  
  10. System.out.println(v1);
  11.  
  12. for (int i = 1; i < 5; i++) {
  13. v1.forward();
  14. System.out.println(v1);
  15. }
  16. System.out.println(v1.getLocation());
  17.  
  18. for (int i = 1; i < 10; i++) {
  19. int d = (int) (Math.random() * 2);
  20. if (d == 0)
  21. v1.forward();
  22. else
  23. v1.backward();
  24. System.out.println(v1);
  25.  
  26. }
  27.  
  28. Vehicle v2 = new Vehicle(87);
  29. System.out.println(v2.getLocation());
  30.  
  31. Vehicle v3 = new Vehicle(-18);
  32. System.out.println(v3);
  33. v3.backward();
  34. System.out.println(v3.getLocation());
  35. v3.backward();
  36. System.out.println(v3.getLocation());
  37. v3.backward();
  38. System.out.println(v3.getLocation());
  39. v3.backward();
  40. System.out.println(v3.getLocation());
  41.  
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment