-
Notifications
You must be signed in to change notification settings - Fork 6
/
OnBoarding.txt
45 lines (39 loc) · 1.58 KB
/
OnBoarding.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.*;
import java.io.*;
import java.math.*;
/**
* The code below will read all the game information for you.
* On each game turn, information will be available on the standard input, you will be sent:
* -> the total number of visible enemies
* -> for each enemy, its name and distance from you
* The system will wait for you to write an enemy name on the standard output.
* Once you have designated a target:
* -> the cannon will shoot
* -> the enemies will move
* -> new info will be available for you to read on the standard input.
**/
class Player {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
String nom_enemi = "HotDroid";
int minDist = 100000;
// game loop
while (true) {
int count = in.nextInt(); // The number of current enemy ships within range
in.nextLine();
for (int i = 0; i < count; i++) {
String enemy = in.next(); // The name of this enemy
System.err.println(enemy);
int dist = in.nextInt(); // The distance to your cannon of this enemy
in.nextLine();
if(i == 0 || dist < minDist){
minDist = dist;
nom_enemi = enemy;
}
}
// Write an action using System.out.println()
// To debug: System.err.println("Debug messages...");
System.out.println(nom_enemi); // The name of the most threatening enemy (HotDroid is just one example)
}
}
}