Beispiel #1
0
 private static async Task <Laundry> RunDryer(Laundry laundry)
 {
     return(await Task.Run(() => {
         sim.Log("Tumble dryer is running.");
         dryer.Dry(laundry);
         return (laundry);
     }));
 }
Beispiel #2
0
 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)");
 }
Beispiel #4
0
 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)");
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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)");
 }
Beispiel #8
0
 private static void PutAwayDryClothes(Laundry laundry)
 {
     laundry.State = LaundryState.PutAway;
     sim.Log("Dry clothes have been put away.");
 }
Beispiel #9
0
 private static Laundry RunDryer(Laundry laundry)
 {
     sim.Log("Tumble dryer is running.");
     dryer.Dry(laundry);
     return(laundry);
 }