@Test public void testNextState5() { State currentState = State.DEAD; int liveNeighbours = 3; RuleImpl instance = new RuleImpl(); State expResult = State.LIVE; State result = instance.nextState(currentState, liveNeighbours); assertEquals(expResult, result); }
@Override public State nextState(State currentState, int liveNeighbours) { if(State.LIVE.equals(currentState)) { if(liveNeighbours==2 || liveNeighbours==3) { return State.LIVE; } else return State.DEAD; } else if(State.DEAD.equals(currentState)) { if(liveNeighbours == 3) { return State.LIVE; } } return currentState; }
RuleImpl implements Rule { @Override public State nextState(State currentState, int liveNeighbours) { if(State.LIVE.equals(currentState)) { if(liveNeighbours==2 || liveNeighbours==3) { return State.LIVE; } else return State.DEAD; } else if(State.DEAD.equals(currentState)) { if(liveNeighbours == 3) { return State.LIVE; } } return currentState; } }
RuleImpl implements Rule { @Override public State nextState(State currentState, int liveNeighbours) { if(State.LIVE.equals(currentState)) { if(liveNeighbours==2 || liveNeighbours==3) { return State.LIVE; } else return State.DEAD; } else if(State.DEAD.equals(currentState)) { if(liveNeighbours == 3) { return State.LIVE; } } return currentState; }  }
RuleImpl implements Rule { @Override public State nextState(State currentState, int liveNeighbours) { if(State.LIVE.equals(currentState)) { if(liveNeighbours==2 || liveNeighbours==3) { return State.LIVE; } else return State.DEAD; } else if(State.DEAD.equals(currentState)) { if(liveNeighbours == 3) { return State.LIVE; } } return currentState; }  @Override State nextState(State currentState, int liveNeighbours); }
RuleImpl implements Rule { @Override public State nextState(State currentState, int liveNeighbours) { if(State.LIVE.equals(currentState)) { if(liveNeighbours==2 || liveNeighbours==3) { return State.LIVE; } else return State.DEAD; } else if(State.DEAD.equals(currentState)) { if(liveNeighbours == 3) { return State.LIVE; } } return currentState; }  @Override State nextState(State currentState, int liveNeighbours);  }