title: Java Basic Memory Matching Game
body: <p>I am trying to code a 4x4 memory matching game that has 8 identical number pairs. All face down cards are marked by an asterisk. Then the user inputs (1,1) and (1,2) as a guess and if correct they remain face up and the game continues.</p>
  
  <p>My Problem: I have most of the code complete however my method <em>game</em> which runs the game I cannot figure out how to set it up. Any advice would be appreciated.</p>
  
  <p>My Code:</p>
  
  <pre><code>     //Welcome Prompt
      System.out.println("Welcome to the memory matching game!");
      System.out.println("Enter the card coordinate for each card when promted to.");
      System.out.println("For Example, 11 = Card 1 and 12 = Card 2.\n\n");
  
      board();
  }
  
  //print the board
  public static void board() {
      int[][] cards = new int[4][4];
      boolean upDown[][] = new boolean[4][4];
  
      cards = randomizer(); //Shuffle cards       
      System.out.println("     1 2 3 4 ");
      System.out.println("---+---------");
      for (int i = 0; i &lt; 4; i++) {
          System.out.print(" " + (i + 1) + " | ");
          for (int a = 0; a &lt; 4; a++) {
              System.out.print("* ");
              upDown[i][a] = false;
          }
          System.out.println();
      }
      System.out.println();
      game(upDown, cards); // calls the game
  }
  
  public static int[][] randomizer() {
      int num[] = {1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8};
      int cards[][] = new int[4][4];
      Random random = new Random();
      int temp, t;
      for (int j = 0; j &lt;= 20; j++) {
          for (int x = 0; x &lt; 16; x++) { //Randomize the card order
              t = random.nextInt(1000) % 15;
              temp = num[x];
              num[x] = num[t];
              num[t] = temp;
  
          }
          t = 0;
          for (int r = 0; r &lt; 4; r++) // Cards receive Numbers
          {
              for (int s = 0; s &lt; 4; s++) {
                  cards[r][s] = num[t];
                  t = t + 1;
              }
          }
  
      }
      return cards;
  }
  
  //Start the Game
  public static void game(boolean[][] upDown, int[][] cards) {
  
  }
  
  //shuffle the cards
  public static int[][] shuf() {
      int start[] = {1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8};
      int cards[][] = new int[4][4];
      Random ran = new Random();
      int tmp, i;
      for (int s = 0; s &lt;= 20; s++) {
          for (int x = 0; x &lt; 16; x++) //randomize the card placements
          {
              i = ran.nextInt(100000) % 15;
              tmp = start[x];
              start[x] = start[i];
              start[i] = tmp;
          }
      }
      i = 0;
  
      for (int r = 0; r &lt; 4; r++) // put values in cards here
      {
          for (int c = 0; c &lt; 4; c++) {
              cards[r][c] = start[i];
              i = i + 1;
          }
      }
      return cards;
  
  }
  }
  </code></pre>