-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayManager.java
More file actions
44 lines (40 loc) · 1.29 KB
/
Copy pathPlayManager.java
File metadata and controls
44 lines (40 loc) · 1.29 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
44
/**
* This file is provided for you to test out your GameState program
* while you work on PA 4. It is not required for submission.
*
* @author Charles Yu, Yingxi Lin
*
* DO NOT MODIFY THIS FILE
*/
/**
* A manager class that runs the 2048 game. It parses command line
* arguments, initializes the game accordingly.
*/
public class PlayManager
{
private static final String USAGE = "`java PlayManager [SAVEFILE]` " +
"to start a game from SAVEFILE, omit for a default game";
private static final String START_MSG =
"Starting a default-sized random game...";
private static final String LOAD_MSG_FMT =
"Attempting to load game from %s..";
/**
* Main method. Parses command line arg, load games, run games.
* @param args an array of command line args in Strings
*/
public static void main (String[] args) {
if (args.length != 0 && args.length != 1) {
System.out.print(USAGE);
return;
}
Game2048 game = null;
if (args.length == 0) {
System.out.println(START_MSG);
game = new Game2048();
} else {
System.out.println(String.format(LOAD_MSG_FMT, args[0]));
game = new Game2048(args[0]);
}
game.play();
}
}