From fb8a87bade402b7ddd225f8554bfe5a3af4d2682 Mon Sep 17 00:00:00 2001 From: Thomas Kwashnak Date: Wed, 5 Jan 2022 11:59:12 -0500 Subject: [PATCH] Added the board matrix --- 48_High_IQ/java/src/Board.java | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/48_High_IQ/java/src/Board.java b/48_High_IQ/java/src/Board.java index 18b17cf5..6a320bd1 100644 --- a/48_High_IQ/java/src/Board.java +++ b/48_High_IQ/java/src/Board.java @@ -1,10 +1,28 @@ public class Board { - public Board() { - - } + private int[][] board; - public String toString() { - return ""; - } + public Board() { + board = new int[7][7]; + + //Set all of the corners to -1, and place pegs in proper spaces + for(int i = 0; i < 7; i++) { + for(int j = 0; j < 7; j++) { + if((i < 3 || i > 5) && (j < 3 || j > 5)) { + //If both i and j are either less than 3 or greater than 5, then the index is a corner + board[i][j] = -1; + } else if(i == 4 && j == 4) { + //Do not place a peg in the center + board[i][j] = 0; + } else { + //Place a peg everywhere else + board[i][j] = 1; + } + } + } + } + + public String toString() { + return ""; + } }