// Step through simulation. // It simulates passage of time. Changes internal state. private void step(Integer stepHours) { LifeState lifeState = tamagotchi.getLifeState(); PhysicalState physicalState = tamagotchi.getPhysicalState(); Integer age = tamagotchi.getAge(); Integer hungerIndex = tamagotchi.getHungerIndex(); currentHour += stepHours; if (currentHour > 24) { currentDay = +1; currentHour = currentHour % 24; age = +1; } // Losses energy and get aged as time passes. tamagotchi.loseHealth(stepHours); tamagotchi.setAge(age); lifeState.action(tamagotchi); physicalState.action(tamagotchi, currentHour); }