forked from Liidiacnog/BuffyTheVampireSlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuffyTheVampireSlayer.java
More file actions
43 lines (39 loc) · 1.38 KB
/
Copy pathBuffyTheVampireSlayer.java
File metadata and controls
43 lines (39 loc) · 1.38 KB
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
import java.util.Scanner;
import logic.Level;
import control.Controller;
import logic.Game;
public class BuffyTheVampireSlayer {
public static final String version = "3.0";
public static final String usageMsg = "Usage: Vampire slayer <level> [seed]";
public static final String welcomeMsg = String.format("Buffy the Vampire Slayer " + version + "%n");
public static final String levelInfoMsg = "Level must be one of: " + Level.all(", ");
public static final String seedIsNumberMsg = "the seed must be a number";
public static final String seedInfoMsg = "Random generator initialized with seed: ";
public static void main(String[] args) {
if (args.length < 1 || args.length > 2)
System.out.print(usageMsg);
else {
Level level = Level.parse(args[0]);
if(level == null) {
System.out.println(usageMsg);
System.out.println(levelInfoMsg);
}
else {
Long seed;
try {
if (args.length == 2)
seed = Long.parseLong(args[1]);
else
seed = System.currentTimeMillis();
System.out.print(welcomeMsg);
System.out.println(seedInfoMsg + seed);
Controller controller = new Controller(new Game(seed, level), new Scanner(System.in));
controller.run();
}
catch (NumberFormatException nfe) {
System.out.println(usageMsg + ": " + seedIsNumberMsg);
}
}
}
}
}