public ClothingResponse Execute(ref Person person, Weather weather) { ClothingResponse response = new ClothingResponse() { IsSuccessful = false, Response = "fail" }; if (person.IsWearing(Clothing.Footwear)) { return(response); } if (person.IsWearing(Clothing.Pajamas)) { return(response); } if (!person.IsWearing(Clothing.Pants)) { return(response); } if (!person.IsWearing(Clothing.Socks) && weather == Weather.Cold) { return(response); } person.Wear(Clothing.Footwear); return(new ClothingResponse() { IsSuccessful = true, Response = weather == Weather.Hot ? "sandals" : "boots" }); }
public ClothingResponse Execute(ref Person person, Weather weather) { ClothingResponse response = new ClothingResponse() { IsSuccessful = false, Response = "fail" }; if (person.IsWearing(Clothing.Pants)) { return(response); } if (person.IsWearing(Clothing.Pajamas)) { return(response); } person.Wear(Clothing.Pants); return(new ClothingResponse() { IsSuccessful = true, Response = weather == Weather.Hot ? "shorts" : "pants" }); }
public ClothingResponse Execute(ref Person person, Weather weather) { ClothingResponse response = new ClothingResponse() { IsSuccessful = false, Response = "fail" }; if (person.IsWearing(Clothing.Jacket)) { return(response); } if (person.IsWearing(Clothing.Pajamas)) { return(response); } if (weather == Weather.Hot) { return(response); } if (!person.IsWearing(Clothing.Shirt)) { return(response); } person.Wear(Clothing.Jacket); return(new ClothingResponse() { IsSuccessful = true, Response = "jacket" }); }
public ClothingResponse Execute(ref Person person, Weather weather) { ClothingResponse response = new ClothingResponse() { IsSuccessful = false, Response = "fail" }; if (person.IsWearing(Clothing.Headwear)) { return(response); } if (person.IsWearing(Clothing.Pajamas)) { return(response); } if (!person.IsWearing(Clothing.Shirt)) { return(response); } person.Wear(Clothing.Headwear); return(new ClothingResponse() { IsSuccessful = true, Response = weather == Weather.Hot ? "sun visor" : "hat" }); }
public ClothingEngine(List <int> actions) { ClothingResponse response = new ClothingResponse() { IsSuccessful = false, Response = "failed" }; // Load the rules in order... // foreach (int action in actions) { rules.Add(ClothingRulesFactory.GetRule(action)); } }
public ClothingResponse Execute(ref Person person, Weather weather) { ClothingResponse response = new ClothingResponse() { IsSuccessful = false, Response = "fail" }; if (person.IsWearing(Clothing.Pajamas)) { return(response); } if (!person.IsWearing(Clothing.Footwear)) { return(response); } if (!person.IsWearing(Clothing.Headwear)) { return(response); } if (!person.IsWearing(Clothing.Socks) && weather == Weather.Cold) { return(response); } if (!person.IsWearing(Clothing.Shirt)) { return(response); } if (!person.IsWearing(Clothing.Jacket) && weather == Weather.Cold) { return(response); } if (!person.IsWearing(Clothing.Pants)) { return(response); } return(new ClothingResponse() { IsSuccessful = true, Response = "leaving house" }); }
public ClothingResponse Execute(ref Person person, Weather weather) { ClothingResponse response = new ClothingResponse() { IsSuccessful = false, Response = "fail" }; if (person.IsWearing(Clothing.Pajamas)) { person.Remove(Clothing.Pajamas); response = new ClothingResponse() { IsSuccessful = true, Response = "removing PJ's" }; } return(response); }
public void ExecuteRules(Person person, Weather weather) { // Execute the rules in order... // foreach (IClothingRule rule in rules) { //Console.WriteLine("Executing " + rule.GetType().ToString() + "..."); ClothingResponse response = rule.Execute(ref person, weather); Console.Write(response.Response); if (response.IsSuccessful && response.Response != "leaving house") { Console.Write(", "); } if (!response.IsSuccessful) { return; } } }