@Test public void shouldRotateStationIds(){ int valueOne = stationIdService.getStationId(); int valueTwo = stationIdService.getStationId(); int valueThree = stationIdService.getStationId(); int valueFour = stationIdService.getStationId(); int valueFive = stationIdService.getStationId(); int valueSix = stationIdService.getStationId(); assertThat(valueOne).isEqualTo(1); assertThat(valueTwo).isEqualTo(2); assertThat(valueThree).isEqualTo(3); assertThat(valueFour).isEqualTo(1); assertThat(valueFive).isEqualTo(2); assertThat(valueSix).isEqualTo(3); }
public int getStationId(){ if(previousStationIndex == null || isLastIndex()){ previousStationIndex = 0; }else{ previousStationIndex = previousStationIndex + 1; } return stationIds[previousStationIndex]; }
StationIdService { public int getStationId(){ if(previousStationIndex == null || isLastIndex()){ previousStationIndex = 0; }else{ previousStationIndex = previousStationIndex + 1; } return stationIds[previousStationIndex]; } }
StationIdService { public int getStationId(){ if(previousStationIndex == null || isLastIndex()){ previousStationIndex = 0; }else{ previousStationIndex = previousStationIndex + 1; } return stationIds[previousStationIndex]; }  }
StationIdService { public int getStationId(){ if(previousStationIndex == null || isLastIndex()){ previousStationIndex = 0; }else{ previousStationIndex = previousStationIndex + 1; } return stationIds[previousStationIndex]; }  int getStationId(); }
StationIdService { public int getStationId(){ if(previousStationIndex == null || isLastIndex()){ previousStationIndex = 0; }else{ previousStationIndex = previousStationIndex + 1; } return stationIds[previousStationIndex]; }  int getStationId();  }