Пример #1
0
 public void doTurn(int pitIndex) {
   // if current player doesn't get second, go to next one
   boolean playAgain = board.makeMove(currentPlayerIndex, pitIndex);
   // check if need to keep going or stop the game
   if (board.hasMoreStones(currentPlayerIndex)) {
     if (!playAgain) {
       currentPlayerIndex = board.getNextPlayerIndex(currentPlayerIndex);
     }
   }
   // stop the game
   else {
     // change player index to next player with stones left
     currentPlayerIndex = board.getNextPlayerIndex(currentPlayerIndex);
     // grab anything left on other side
     board.emptyPits(currentPlayerIndex);
     isDone = true;
   }
 }
Пример #2
0
 public int getScore(int playerIndex) {
   return board.getScore(playerIndex);
 }
Пример #3
0
 // question for professor: what does it mean we methods repeat from lower level classes to upper
 // classes ?
 public int[] getPitsCounts(int playerIndex) {
   return board.getPitsCounts(playerIndex);
 }