Project 0: 2048
An introductory project - get familiar with Java and the workflow of an assignment.
Helper methods:
public static boolean emptySpaceExists(Board b)
public static boolean emptySpaceExists(Board b) Solution:
/** Returns true if at least one space on the Board is empty.
* Empty spaces are stored as null.
*/
public static boolean emptySpaceExists(Board b) {
for (int i = 0; i < b.size(); i += 1) {
for (int j = 0; j < b.size(); j += 1) {
if (b.tile(i, j) == null) {
return true;
}
}
}
return false;
}public static boolean maxTileExists(Board b)
public static boolean maxTileExists(Board b) Solution:
public static boolean atLeastOneMoveExists(Board b)
public static boolean atLeastOneMoveExists(Board b)Solution:
Main Task: Building the Game Logic
public void tilt(Side side)
public void tilt(Side side)Solution:
Last updated