public CoffeeDrinker(EnvironmentWithLogging env, TimeSpan workingHours, int number, CoffeeMachine[] coffeeMachines) { _env = env; _workingHours = workingHours; _number = number; _coffeeMachines = coffeeMachines; _stats = new Stats(); _env.Process(GoToWork()); }
public IEnumerable <Event> GoToWork() { //Arrive at office around 09:00 yield return(_env.TimeoutNormalPositive(TimeSpan.FromHours(9), TimeSpan.FromHours(0.5))); _arrivalTime = _env.Now.TimeOfDay; Log($"Arrived at the office, grabbing coffee :)"); yield return(_env.Process(GetCoffee())); while (_env.Now.TimeOfDay < _arrivalTime.Add(_workingHours)) { //Wait for a few hours yield return(_env.TimeoutNormalPositive(TimeSpan.FromHours(2), TimeSpan.FromMinutes(10))); //More coffee yield return(_env.Process(GetCoffee())); } Log($"Time to head home."); }