Package pl.michalostruszka.gameoflife.cell

Examples of pl.michalostruszka.gameoflife.cell.Cell


        return nextBoard;
    }

    private void evolveCellNeighbours(Board nextBoard, Set<Position> neighbours) {
        for (Position neighbourPosition: neighbours) {
            Cell nextNeighbourState = determineCellAt(neighbourPosition).evolveIntoNewState(this);
            nextNeighbourState.attachToBoard(nextBoard);
        }
    }
View Full Code Here


    }

    @Test
    public void shouldEvolveToDeadWhenHasNoLiveNeighbours() throws Exception {
        when(board.countLiveNeighboursOf(CURRENT_CELL)).thenReturn(0);
        Cell nextState = CURRENT_CELL.evolveIntoNewState(board);
        assertThat(nextState).isInstanceOf(DeadCell.class);
    }
View Full Code Here

    }

    @Test
    public void shouldEvolveToLiveWhenHasTwoLiveNeighbour() throws Exception {
        when(board.countLiveNeighboursOf(CURRENT_CELL)).thenReturn(2);
        Cell nextState = CURRENT_CELL.evolveIntoNewState(board);
        assertThat(nextState).isInstanceOf(LiveCell.class);
    }
View Full Code Here

    }

    @Test
    public void shouldEvolveToLiveWhenHasThreeLiveNeighbour() throws Exception {
        when(board.countLiveNeighboursOf(CURRENT_CELL)).thenReturn(3);
        Cell nextState = CURRENT_CELL.evolveIntoNewState(board);
        assertThat(nextState).isInstanceOf(LiveCell.class);
    }
View Full Code Here

    }

    @Test
    public void shouldEvolveToDeadWhenHasFourLiveNeighbour() throws Exception {
        when(board.countLiveNeighboursOf(CURRENT_CELL)).thenReturn(5);
        Cell nextState = CURRENT_CELL.evolveIntoNewState(board);
        assertThat(nextState).isInstanceOf(DeadCell.class);
    }
View Full Code Here

TOP

Related Classes of pl.michalostruszka.gameoflife.cell.Cell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.