task 9 and 10: Added using state class

This commit is contained in:
2023-04-24 17:36:20 +10:00
parent 8ed19d75bd
commit 899497d037
5 changed files with 107 additions and 12 deletions

View File

@@ -616,7 +616,8 @@ public class BlueLagoon {
* @return true if the state is at the end of either phase and false otherwise
*/
public static boolean isPhaseOver(String stateString){
return false; // FIXME Task 9
State state = new State(stateString);
return state.isPhaseOver();
}
/**
@@ -631,7 +632,14 @@ public class BlueLagoon {
* @return a new state string achieved by placing the move on the board
*/
public static String placePiece(String stateString, String moveString){
return ""; // FIXME Task 10
State state = new State(stateString);
char pieceType = moveString.charAt(0);
String coordStr = moveString.substring(2);
int x = Integer.parseInt(coordStr.split(",")[0]);
int y = Integer.parseInt(coordStr.split(",")[1]);
Coord coord = new Coord(x, y);
state.placePiece(coord, pieceType);
return state.toString();
}