CheckersState extends TwoDimensionalBoardGameState { public List<Integer> getWinners(){ if(endState() && winners.size() == 0){ int blackChecksLeft = 0; int redChecksLeft = 0; for(int i = 0; i < BOARD_WIDTH; i++){ for(int j = 0; j < BOARD_WIDTH; j++){ int space = boardState[i][j]; if(space == BLACK_CHECK || space == BLACK_CHECK_KING){ blackChecksLeft++; }else if(space == RED_CHECK || space == RED_CHECK_KING){ redChecksLeft++; } } } if(blackChecksLeft > redChecksLeft){ winners.add(BLACK_CHECK); }else if(redChecksLeft > blackChecksLeft){ winners.add(RED_CHECK); }else{ winners.add(BLACK_CHECK); winners.add(RED_CHECK); } } return winners; } CheckersState();  CheckersState(CheckersState state);   CheckersState(int[][] newBoard, int player, List<Integer> win); int getNumPlayers(); List<Integer> getWinners(); @Override boolean endState(); @Override double[] getDescriptor(); @Override boolean moveDoublePoint(Point moveThis, Point moveTo); @SuppressWarnings("unchecked") @Override CheckersState copy(); @SuppressWarnings("unchecked") @Override Set<T> possibleBoardGameStates(T currentState); @Override void setupStartingBoard(); @Override int getBoardWidth(); @Override int getBoardHeight(); @Override char[] getPlayerSymbols(); @Override Color[] getPlayerColors(); @Override boolean moveSinglePoint(Point goTo); @Override boolean moveOnePiece(); static final int BOARD_WIDTH; static final int STARTCHECKS; static final int BLACK_CHECK; static final int BLACK_CHECK_KING; static final int RED_CHECK; static final int RED_CHECK_KING; public Point doubleJumpCheck; }
@Test public void testGetWinners() { assertEquals(new ArrayList<Integer>(), start.getWinners()); assertEquals(new ArrayList<Integer>(), test1.getWinners()); assertEquals(new ArrayList<Integer>(), test2.getWinners()); List<Integer> win3 = new ArrayList<Integer>(); win3.add(1); assertEquals(win3, test3.getWinners()); assertEquals(new ArrayList<Integer>(), test6.getWinners()); List<Integer> win7 = new ArrayList<Integer>(); win7.add(0); win7.add(1); assertEquals(win7, test7.getWinners()); List<Integer> win8 = new ArrayList<Integer>(); win8.add(1); assertEquals(win8, test8.getWinners()); }