Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ccc1 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- float distance = -1;
- float speed = 0.0f;
- //Speedlimits
- float currentlimit = 1000.0f;
- float distanceToNextLimit = 1000.0f;
- float nextlimit = 1000.0f;
- float simulationStep = 1/60.0f;
- float brake = -21.0f;
- while(scan.hasNextLine()) {
- String s = scan.nextLine();
- if(s.contains("distance")) {
- distance = Float.parseFloat(s.substring(9));
- }
- if(s.contains("speed")) {
- System.out.println(s.substring(6));
- }
- if(s.contains("speedlimit")) {
- String split[] = s.split(" ");
- currentlimit = Float.parseFloat(split[1]);
- distanceToNextLimit = Float.parseFloat(split[2]);
- nextlimit = Float.parseFloat(split[3]);
- }
- if(s.contains("update")) {
- if(distance < 1500) {
- float deltaSpeed = speed - nextlimit;
- double brakeWay = Math.pow(deltaSpeed, 2) / 2 * 5.8f;
- if(brakeWay >= distanceToNextLimit) {
- System.out.println("throttle 0");
- System.out.println("brake 100");
- } else {
- if(speed < currentlimit) {
- System.out.println("throttle 100");
- System.out.println("brake 0");
- } else {
- System.out.println("throttle 0");
- System.out.println("brake 0");
- }
- }
- } else {
- System.out.println("throttle 0");
- System.out.println("brake 100");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement