Guest User

Skynet: the Chasm

a guest
Sep 21st, 2014
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Player {
  4.    
  5.     public static void out(String val) {System.out.println(val);}
  6.     public static int scan(Scanner in) {int i = in.nextInt();in.nextLine();return i;}
  7.  
  8.     public static void main(String args[]) {
  9.         Scanner in = new Scanner(System.in);
  10.         int R = scan(in); // the length of the road before the gap.
  11.         int G = scan(in); // the length of the gap.
  12.         int L = scan(in); // the length of the landing platform.
  13.  
  14.         int OK_SPEED = G+1;
  15.         int JUMP_START = R-3;
  16.  
  17.         boolean jumped = false;
  18.        
  19.         // game loop
  20.         while (true) {
  21.             int S = scan(in); // the motorbike's speed.
  22.             int X = scan(in); // the position on the road of the motorbike.
  23.  
  24.             if (X>JUMP_START)
  25.             {
  26.                 if (!jumped)
  27.                 {
  28.                     out("JUMP");
  29.                     jumped = true;
  30.                 }
  31.                 else out("SLOW");
  32.             }
  33.             else
  34.             if (S>OK_SPEED) out("SLOW");
  35.             else if (S<OK_SPEED) out("SPEED");
  36.             else out("WAIT");
  37.            
  38.            
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment