| 8 | import java.util.Random; |
| 9 | |
| 10 | public class MemoryGame { |
| 11 | /** The width of the window of this game. */ |
| 12 | private int width; |
| 13 | /** The height of the window of this game. */ |
| 14 | private int height; |
| 15 | /** The current round the user is on. */ |
| 16 | private int round; |
| 17 | /** The Random object used to randomly generate Strings. */ |
| 18 | private Random rand; |
| 19 | /** Whether or not the game is over. */ |
| 20 | private boolean gameOver; |
| 21 | /** Whether or not it is the player's turn. Used in the last section of the |
| 22 | * spec, 'Helpful UI'. */ |
| 23 | private boolean playerTurn; |
| 24 | /** The characters we generate random Strings from. */ |
| 25 | private static final char[] CHARACTERS = "abcdefghijklmnopqrstuvwxyz".toCharArray(); |
| 26 | /** Encouraging phrases. Used in the last section of the spec, 'Helpful UI'. */ |
| 27 | private static final String[] ENCOURAGEMENT = {"You can do this!", "I believe in you!", |
| 28 | "You got this!", "You're a star!", "Go Bears!", |
| 29 | "Too easy for you!", "Wow, so impressive!"}; |
| 30 | |
| 31 | public static void main(String[] args) { |
| 32 | if (args.length < 1) { |
| 33 | System.out.println("Please enter a seed"); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | long seed = Long.parseLong(args[0]); |
| 38 | MemoryGame game = new MemoryGame(40, 40, seed); |
| 39 | game.startGame(); |
| 40 | } |
| 41 | |
| 42 | public MemoryGame(int width, int height, long seed) { |
| 43 | /* Sets up StdDraw so that it has a width by height grid of 16 by 16 squares as its canvas |
| 44 | * Also sets up the scale so the top left is (0,0) and the bottom right is (width, height) |
| 45 | */ |
| 46 | this.width = width; |
| 47 | this.height = height; |
| 48 | StdDraw.setCanvasSize(this.width * 16, this.height * 16); |
| 49 | Font font = new Font("Monaco", Font.BOLD, 30); |
| 50 | StdDraw.setFont(font); |
| 51 | StdDraw.setXscale(0, this.width); |
| 52 | StdDraw.setYscale(0, this.height); |
| 53 | StdDraw.clear(Color.BLACK); |
| 54 | StdDraw.enableDoubleBuffering(); |
| 55 | |
| 56 | this.rand = new Random(seed); |
| 57 | } |
| 58 | |
| 59 | public String generateRandomString(int n) { |
| 60 | //TODO: Generate random string of letters of length n |
| 61 | return null; |
| 62 | } |
| 63 | |
| 64 | public void drawFrame(String s) { |
| 65 | /* Take the input string S and display it at the center of the screen, |
| 66 | * with the pen settings given below. */ |
| 67 | StdDraw.clear(Color.BLACK); |
nothing calls this directly
no outgoing calls
no test coverage detected