Game implements IGame { @Override public void onRequestFlag(final IField fieldInterface) { if (!isMined()) { onRequestOpen(fieldInterface); return; } Field field = (Field) fieldInterface; if (isFinished()) return; itsBoard.updateLastTouched(field); if (!field.isOpen()) { if (!isAllFlagsUsed() || field.isFlagged()) { toggleFlag(field); fireChange(); } } else openNeighborsIfFullyFlagged(field); handleGameDone(); } Game(final int dimX, final int dimY, final int bombs, final IBoardMiner miner); private  Game(final GameState state, final IBoardMiner miner); @Override void addListener(final IMinesGameListener listener); @Override IBoard getBoard(); @Override int getBombCount(); @Override void onRequestFlag(final IField fieldInterface); @Override void onRequestOpen(final IField fieldInterface); @Override boolean isStarted(); @Override boolean isRunning(); @Override void removeListener(final IMinesGameListener listener); @Override String toString(); static Game createFromState(final GameState state, final IBoardMiner miner); GameState getState(); @Override IStopWatch getWatch(); @Override void tickWatch(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testFlagFlaggedField() { Game game = new Game(2, 2, 2, new TestBoardMiner(new boolean[][]{{false, false}, {true, true}})); openAt(0, 0, game); IField field = flagAt(1, 1, game); game.onRequestFlag(field); assertEquals(false, field.isFlagged()); }
@Test public void testFlagOpenField() { IField field = openAt(0, 0, itsGame2by1); itsGame2by1.onRequestFlag(field); assertEquals(false, field.isFlagged()); }
@Test public void testOpenUnflaggedNeighborsOnFlaggingAnOpenField() { testOpenUnflaggedNeighbors(new Runnable() { @Override public void run() { itsGame2by2.onRequestFlag(its2by2UpLeft); } }); }