private static async Task <Laundry> RunDryer(Laundry laundry) { return(await Task.Run(() => { sim.Log("Tumble dryer is running."); dryer.Dry(laundry); return (laundry); })); }
private static async Task <Laundry> RunWashingMachine(Laundry laundry) { return(await Task.Run(() => { sim.Log("Washing machine is running."); washer.Wash(laundry); return laundry; })); }
public void Dry(Laundry laundry) { if (laundry.State != LaundryState.Wet) { throw (new Exception("FOR BEST RESULTS ENSURE LAUNDRY IS WET BEFORE ATTEMPTING TO DRY IT.")); } sim.DoWork(TimeSpan.FromHours(3)); laundry.State = LaundryState.Dry; sim.Report("(tumble dryer has finished)"); }
public void Wash(Laundry laundry) { for (int i = 0; i < 5; i++) { if (random.Next(2) == 1) { sim.Report("A mysterious burning smell..."); laundry.State = LaundryState.OnFire; throw (new Exception("Washing machine on fire!")); } sim.DoWork(TimeSpan.FromHours(0.5)); } laundry.State = LaundryState.Wet; sim.Report("(washing machine has finished)"); }
private static async Task CleanAllTheThings() { var laundry = new Laundry() { State = LaundryState.Dirty }; var wash = RunWashingMachine(laundry); CleanBathroom(); CheckLaundry(wash); CleanLivingRoom(); CheckLaundry(wash); CleanKitchen(); await CheckLaundry(wash); }
private static async Task CleanAllTheThings() { var laundry = new Laundry() { State = LaundryState.Dirty }; var washCycle = RunWashingMachine(laundry); CleanBathroom(); CheckLaundry(washCycle); CleanLivingRoom(); CheckLaundry(washCycle); CleanKitchen(); CheckLaundry(washCycle); PutAwayDryClothes(laundry); }
public void Wash(Laundry laundry) { sim.DoWork(TimeSpan.FromHours(3.5)); laundry.State = LaundryState.Wet; sim.Report("(washing machine has finished)"); }
private static void PutAwayDryClothes(Laundry laundry) { laundry.State = LaundryState.PutAway; sim.Log("Dry clothes have been put away."); }
private static Laundry RunDryer(Laundry laundry) { sim.Log("Tumble dryer is running."); dryer.Dry(laundry); return(laundry); }