/** * 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 */ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; /** * A class that creates the 2048 game. It can create default games, * or load saved games. */ public class Game2048 { GameState currentState; String filename; private static final String GAME_OVER_MSG = "Game Over!"; private static final String PROMPT_STR = "> "; private static final String CMD_LENGTH_ERR_MSG = "Command must be one char long."; private static final String POSSIBLE_CMDS_STR = "Possible commands:\n w - up\n a - left\n s - down\n " + "d - right\n o - save to file\n q - quit game"; private static final String VALUE_SEP = " "; private static final String SAVED_MSG = "Saved current state to: "; /** * Default constructor that create the game based on settings in * `Config.java`. */ public Game2048 () { currentState = new GameState(Config.DEFAULT_SIZE, Config.DEFAULT_SIZE); filename = Config.DEFAULT_OUTFILE; for (int i=0; i