示例#1
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)");
 }
 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)
 {
     sim.DoWork(TimeSpan.FromHours(3.5));
     laundry.State = LaundryState.Wet;
     sim.Report("(washing machine has finished)");
 }