int
, where each array index represents a pile of matches and the number stored at each index represents the number of matchsticks in that pile.int piles[]
: an array that represent the piles of matchsticksint player
: represents the current player (the player about to make a move). Valid values for player
can be either 0
or 1
.protected void populateEmptyBoard(int minMatches, int maxMatches)
minMatches
parameter represents the minimum number of matches that
can populate any given pilemaxMatches
parameter represents the maximum number of matches that
can populate any given pilepublic boolean isValidMove(int whichPile, int numMatches)
:
whichPile
specifies which pile to remove matches from (0-indexed)numMatches
specifies how many matches to movepublic void makeMove(int whichPile, int numMatches)
:
whichPile
The pile to remove matches fromnumMatches
How many matches to removepublic boolean isGameOver()
:
public String toString()
:
The game operates as follows.