public override void ProcessResources() { Resources.ForEach(animal => { IMeatProducing resource = (IMeatProducing)animal; System.Console.WriteLine($"{resource.Butcher()}kg of meat was produced"); }); }
public static void CollectInput(Farm farm, IMeatProducing animal) { Utils.Clear(); for (int i = 0; i < farm.ChickenHouses.Count; i++) { Console.WriteLine($"{i + 1}. Chicken House"); } Console.WriteLine(); // How can I output the type of animal chosen here? Console.WriteLine($"Place the animal where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); farm.ChickenHouses[choice - 1].AddResource(animal); /* * Couldn't get this to work. Can you? * Stretch goal. Only if the app is fully functional. */ // farm.PurchaseResource<IGrazing>(animal, choice); }
public static void CollectInput(Farm farm, IMeatProducing meat) { foreach (GrazingField field in farm.GrazingFields) { int i = 1; Console.WriteLine($"Grazing field #{i} has: {field.NumberOfAnimals} ready to butcher"); i++; } }
public static void CollectInput(Farm farm, IMeatProducing meat) { for (int i = 0; i < farm.GrazingFields.Count; i++) { Console.Clear(); foreach (GrazingField gf in farm.GrazingFields) { if (gf.Animals.GetType().Name.ToString() == "ICompost") { Console.WriteLine($"{i + 1}. {farm.GrazingFields[i]}"); } } } }
public void ProcessResults(List <IResource> resProcessed) { Dictionary <string, double> meatProduced = new Dictionary <string, double>(); resProcessed.ForEach(animal => { IMeatProducing resource = (IMeatProducing)animal; try { meatProduced.Add(resource.GetType().Name, resource.Butcher()); } catch (Exception) { meatProduced[resource.GetType().Name] += resource.Butcher(); } }); foreach (KeyValuePair <string, double> animal in meatProduced) { System.Console.WriteLine($"{animal.Value}kg of {animal.Key} meat was produced"); } }
public static void CollectInput(Farm farm, IMeatProducing animal) { Utils.Clear(); for (int i = 0; i < farm.DuckHouses.Count; i++) { Console.WriteLine($"{i + 1}. {farm.DuckHouses[i]}"); } Console.WriteLine(); // How can I output the type of animal chosen here? Console.WriteLine($"Place the animal where?"); // int32.parse changes string to integer, readline only does integer Console.Write("> "); // converting string to int int choice = Int32.Parse(Console.ReadLine()); // farm.DuckHouses[choice - 1].AddResource(animal); if (farm.DuckHouses[choice - 1].GetTotal() < farm.DuckHouses[choice - 1].Capacity) { farm.DuckHouses[choice - 1].AddResource(animal); } else { Console.WriteLine("This field is full."); Thread.Sleep(2000); } /* * Couldn't get this to work. Can you? * Stretch goal. Only if the app is fully functional. */ // farm.PurchaseResource<IGrazing>(animal, choice); }
public void AddToHopper(IMeatProducing resourceToAdd) { _hopper.Add(resourceToAdd); }