Advertisement
dmesticg

Untitled

Feb 10th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. public class BoardGame {
  4.  
  5.  
  6. private static int board_length;
  7. private static int board_width;
  8. private Snake theSnake;
  9. private String[][] matrix;
  10.  
  11.  
  12. public BoardGame(String boardFile) {
  13. MyFileReader in;
  14. String line;
  15.  
  16. in = new MyFileReader(boardFile);
  17. int placeholder = in.readInt();
  18. placeholder = in.readInt();
  19. int board_length = in.readInt();
  20. int board_width = in.readInt();
  21. int initial_row = in.readInt();
  22. int initial_col= in.readInt();
  23. matrix = new String[board_width][board_length];
  24.  
  25.  
  26. for (int j = 0; j <= board_length-1; j++) {
  27. for (int k = 0; k <= board_width-1; k++)
  28. {
  29. matrix[k][j] = "empty";
  30. }
  31. }
  32.  
  33. while (in.endOfFile() == false) {
  34. int num1 = in.readInt();
  35. int num2 = in.readInt();
  36. String string1 = in.readString();
  37. matrix[num1][num2] = string1;
  38. }
  39.  
  40.  
  41. }
  42.  
  43. public String getObject(int row, int col) {
  44. String string = matrix[row][col];
  45. return string;
  46. }
  47.  
  48. public void setObject(int row, int col, String newObject) {
  49. matrix[row][col] = newObject;
  50. }
  51.  
  52. public Snake getSnake() {
  53. return theSnake;
  54. }
  55.  
  56. public void setSnake(Snake newSnake) {
  57. theSnake = newSnake;
  58. }
  59.  
  60. public static int getLength() {
  61. System.out.println(board_length);
  62. return board_length;
  63. }
  64.  
  65. public static int getWidth() {
  66. return board_width;
  67. }
  68.  
  69. public String getType(int row, int col) {
  70. String string = matrix[row][col];
  71. return string;
  72. }
  73.  
  74. public static void main (String[] args) {
  75. BoardGame theBoardGame = new BoardGame("testboard");
  76. int length = getLength();
  77. }
  78.  
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement