Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class BoardGame {
- private static int board_length;
- private static int board_width;
- private Snake theSnake;
- private String[][] matrix;
- public BoardGame(String boardFile) {
- MyFileReader in;
- String line;
- in = new MyFileReader(boardFile);
- int placeholder = in.readInt();
- placeholder = in.readInt();
- int board_length = in.readInt();
- int board_width = in.readInt();
- int initial_row = in.readInt();
- int initial_col= in.readInt();
- matrix = new String[board_width][board_length];
- for (int j = 0; j <= board_length-1; j++) {
- for (int k = 0; k <= board_width-1; k++)
- {
- matrix[k][j] = "empty";
- }
- }
- while (in.endOfFile() == false) {
- int num1 = in.readInt();
- int num2 = in.readInt();
- String string1 = in.readString();
- matrix[num1][num2] = string1;
- }
- }
- public String getObject(int row, int col) {
- String string = matrix[row][col];
- return string;
- }
- public void setObject(int row, int col, String newObject) {
- matrix[row][col] = newObject;
- }
- public Snake getSnake() {
- return theSnake;
- }
- public void setSnake(Snake newSnake) {
- theSnake = newSnake;
- }
- public static int getLength() {
- System.out.println(board_length);
- return board_length;
- }
- public static int getWidth() {
- return board_width;
- }
- public String getType(int row, int col) {
- String string = matrix[row][col];
- return string;
- }
- public static void main (String[] args) {
- BoardGame theBoardGame = new BoardGame("testboard");
- int length = getLength();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement