-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.java
90 lines (77 loc) · 2.29 KB
/
Board.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
public class Board {
private int num_rows;
private int num_columns;
private int num_boats;
private Battleboat[] boats;
private Cell[][] board;
private boolean debugMode;
// TODO: Assign appropriate number of boats to num_boats variable
// TODO: Initialize the board as a 2-D Cell array
// TODO: Initialize boats as a Battleboat array
// TODO: Place Battleboats appropriately on board and add them to the board's boats
public Board(int m , int n, boolean debugMode){
num_rows = m;
num_columns = n;
num_boats =
this.debugMode = debugMode;
}
//Obscures a character if the game is not being played in debug mode
private char debug(boolean debugMode, char c){
if(debugMode){
return c;
}
else{
switch(c){
case 'H':
c = 'H';
break;
case 'M':
c = 'M';
break;
default:
c = ' ';
break;
}
return c;
}
}
//Prints a Board object in a way that makes sense to the player
public String toString(){
String boardString = "\t";
for (int j = 0; j < num_columns-1; j++){
boardString += j + " |" + "\t";
}
boardString += num_columns-1;
for(int i = 0; i < num_rows; i++){
boardString+= "\n" + i + "\t";
for (int j = 0; j < num_columns; j++){
boardString += debug(debugMode, board[i][j].get_status()) + "\t";
}
}
boardString += "\n";
return boardString;
}
// TODO: Return a int based on the guess for the cell/its status
// TODO: Change the statuses of the cell if applicable
public int guess(int r, int c){
if (){
return 0;
//"Penalty: Out of Bounds";
}
else if () {
return 1;
//"Miss";
}
else if(){
return 2;
//"Hit";
}
else {
return 3;
//"Penalty: Redundant Guess";
}
}
//TODO: write a function that calculates the number of unsunk boats
public int unsunkBoats(){
}
}