MCPcopy Index your code
hub / github.com/careercup/ctci / updateScore

Method updateScore

java/Chapter 8/Question8_8/Board.java:111–122  ·  view source on GitHub ↗
(Color newColor, int newPieces)

Source from the content-addressed store, hash-verified

109 }
110
111 public void updateScore(Color newColor, int newPieces) {
112 /* If we added x pieces of a color, then we actually removed x - 1 pieces of the other
113 * color. The -1 is because one of the new pieces was the just-placed one.
114 */
115 if (newColor == Color.Black) {
116 whiteCount -= newPieces - 1;
117 blackCount += newPieces;
118 } else {
119 blackCount -= newPieces - 1;
120 whiteCount += newPieces;
121 }
122 }
123
124 public void printBoard() {
125 for (int r = 0; r < board.length; r++) {

Callers 1

placeColorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected