public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); // Added the Console.WriteLine and added a 2 second delay before showing the main menu. Console.WriteLine("A new grazing field has been created."); Thread.Sleep(2000); }
public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); Console.WriteLine("Grazing Field has been added"); Console.WriteLine("Press enter key to continue"); Console.ReadLine(); }
//Adds Grazing field when purchasing new facility. public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); Console.WriteLine("Grazing Field Added"); Console.WriteLine("Press enter to return to Main Menu"); Console.ReadLine(); }
public static void CollectInput(Farm farm) { List <IList> list = farm.CreateFacilitiesList(); for (int i = 0; i < list.Count; i++) { if (list[i][0].GetType().Name != "GrazingField" && list[i][0].GetType().Name != "ChickenHouse") { list.RemoveAt(i); i--; } } Console.WriteLine("Select facility type for processing"); for (int i = 0; i < list.Count; i++) { Console.WriteLine($"{i + 1} {list[i][0].GetType().Name}"); } int choice = Convert.ToInt32(Console.ReadLine()); List <GrazingField> grazingAnimalsWithMeat = new List <GrazingField>(); foreach (var item in list[choice - 1]) { if (item.GetType().Name == "GrazingField") { GrazingField grazingFieldToCheck = (GrazingField)(item); foreach (var animal in grazingFieldToCheck.AnimalsCount) { if (animal is IMeatProducing) { grazingAnimalsWithMeat.Add(grazingFieldToCheck); break; } } } else if (item.GetType().Name == "ChickenHouse") { ChickenHouse datThing = (ChickenHouse)(item); } } Console.WriteLine("Select which facility for processing"); for (int i = 0; i < grazingAnimalsWithMeat.Count; i++) { Console.WriteLine($"{i + 1}: {grazingAnimalsWithMeat[i]}"); } int facilityChoice = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How Many?"); int amountToProcess = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < grazingAnimalsWithMeat[facilityChoice].AnimalsCount.Count; i++) { // if(AnimalsCount[i] is Cow){ // //store all the animals in a hashset . display all the animals for our choices. match the hashset key for the type we decide to // //to delete. // } } }
public static void CollectInput(Farm farm, IGrazing animal) { Utils.Clear(); try { for (int i = 1; i <= farm.GrazingFields.Count; i++) { GrazingField field = farm.GrazingFields[i - 1]; if (field.Capacity > field.numOfAnimals()) { // Print out the number of total animals Console.WriteLine($"{i}. Grazing Field {field.shortId()} has {field.numOfAnimals()} animals."); // Print out the counts of each type of animal var counts = field.Animals.GroupBy(animal => animal.Type) .Select(group => new PrintReport { Name = group.Key, Count = group.Count() }); foreach (PrintReport report in counts) { Console.WriteLine($"{report.Name}: {report.Count}"); } } else { Console.WriteLine($"{i}. Grazing Field {field.shortId()} is at capacity with {field.numOfAnimals()} animals."); var counts = field.Animals.GroupBy(animal => animal.Type) .Select(group => new PrintReport { Name = group.Key, Count = group.Count() }); foreach (PrintReport report in counts) { Console.WriteLine($"{report.Name}: {report.Count}"); } } } Console.WriteLine(); Console.WriteLine($"Place the animal where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); farm.GrazingFields[choice - 1].AddResource(animal); } catch { Console.WriteLine("Please enter a valid selection."); Thread.Sleep(1000); CollectInput(farm, animal); } }
public static void CollectInput(Farm farm, IGrazing animal) { Console.Clear(); for (int i = 0; i < farm.GrazingFields.Count; i++) { GrazingField field = farm.GrazingFields[i]; if (field.Capacity > 0) { Console.WriteLine($"{i + 1}. Grazing Field"); Console.WriteLine($"Current animals: {field.GetList().Count}"); var animalsGroupedByType = field._animals.GroupBy(n => n.animal); foreach (var group in animalsGroupedByType) { Console.WriteLine($"{group.Key}: {group.Count()}"); } Console.WriteLine(); } } if (farm.GrazingFields.Count >= 1) { 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()); int index = choice - 1; farm.GrazingFields[index].AddResource(animal); } else { Console.WriteLine("No Field to select from, Please purchase an appropriate facility. "); Console.ReadLine(); } /* * Couldn't get this to work. Can you? * Stretch goal. Only if the app is fully functional. */ // farm.PurchaseResource<IGrazing>(animal, choice); }
public void AddGrazingField(GrazingField field) { try { GrazingFields.Add(field); //Ticket #19 Console.WriteLine("A new grazing field has been created!"); Console.WriteLine("Press enter to continue."); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("Could not add a grazing field."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); } }
public Farm() { FileHandler = new FileHandler(); SeedHarvester = new SeedHarvester(FileHandler); Composter = new Composter(FileHandler); MeatProcessor = new MeatProcessor(FileHandler); FeatherGatherer = new FeatherGatherer(FileHandler); EggGatherer = new EggGatherer(FileHandler); FileHandler.Facilities.ForEach(fac => { IFacility newFacility = null; string[] facilityData = fac.Split(":"); string type = facilityData[0]; string name = facilityData[1]; string data = facilityData[2]; switch (type) { case "Chicken House": newFacility = new ChickenHouse(name, data); break; case "Duck House": newFacility = new DuckHouse(name, data); break; case "Grazing Field": newFacility = new GrazingField(name, data); break; case "Plowed Field": newFacility = new PlowedField(name, data); break; case "Natural Field": newFacility = new NaturalField(name, data); break; default: throw new Exception("Invalid data"); } Facilities.Add(newFacility); }); }
public static void CollectInput(Farm farm, IGrazing animal) { Console.Clear(); GrazingField anyFieldWithRoom = farm.GrazingFields.Find(gf => gf.CurrentCapacity < gf.MaxCapacity); if (anyFieldWithRoom != null) { for (int i = 0; i < farm.GrazingFields.Count; i++) { GrazingField currentField = farm.GrazingFields[i]; if (currentField.CurrentCapacity < currentField.MaxCapacity) { Console.WriteLine($"{i + 1}. Grazing field - {currentField.CurrentCapacity} of {currentField.MaxCapacity} animals\n"); } } Console.WriteLine(); // How can I output the type of animal chosen here? if (UserTriedToSelectAFullFacility) { Console.WriteLine("That facility is already full."); } Console.WriteLine($"Place the animal where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()) - 1; farm.GrazingFields[choice].AddResource(farm, animal); PurchaseStock.ThereIsNoRoomForTheAnimalBeingPurchased = false; } else { PurchaseStock.ThereIsNoRoomForTheAnimalBeingPurchased = true; Program.DisplayBanner(); PurchaseStock.CollectInput(farm); } /* * 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 CollectMeatInput(GrazingField GrazingField) { Utils.Clear(); Console.WriteLine("The following animals are in the Chicken House.\n"); var animalGroups = GrazingField.AnimalTypeGroups(); for (int i = 1; i < animalGroups.Count() + 1; i++) { Console.WriteLine($"{i}. {animalGroups[i - 1].Count()} {animalGroups[i - 1].Key}"); } Console.WriteLine("\nWhich resource should be processed?"); while (true) { var parsedChoice = Int32.Parse(Console.ReadLine()) - 1; if (parsedChoice < 0 || parsedChoice > animalGroups.Count() - 1) { Console.WriteLine("Please enter a valid index range"); } else { Utils.Clear(); Console.WriteLine($"How many {animalGroups[parsedChoice].Key} should be processed?"); Console.Write("> "); var parsedChoice2 = int.Parse(Console.ReadLine()); for (int i = 0; i < parsedChoice2; i++) { var selectedGroup = animalGroups[parsedChoice]; var selectedKey = selectedGroup.Key; var foundAnimal = GrazingField.Animals.FirstOrDefault(animal => animal.Type == selectedKey); GrazingField.Animals.Remove(foundAnimal); } break; } } }
public static void CollectInput(Farm farm, IGrazing animal) { Console.Clear(); for (int i = 0; i < farm.GrazingFields.Count; i++) { if (farm.GrazingFields[i].Animals.Count < farm.GrazingFields[i].Capacity) { GrazingField specificField = farm.GrazingFields[i]; Console.WriteLine($"{i + 1}. {specificField}"); } } Console.WriteLine(); // How can I output the type of animal chosen here? Console.WriteLine($"Place the animal where?"); Console.Write("> "); try { int choice = Int32.Parse(Console.ReadLine()) - 1; farm.GrazingFields[choice].AddResource(animal); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex); } /* * 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 ListResources(Farm farm, string id, string type) { IEnumerable <GrazingField> CorrectFieldEnumerable = from field in farm.GrazingFields where field.ShortId == id select field; List <GrazingField> CorrectFieldList = CorrectFieldEnumerable.ToList(); GrazingField CorrectField = CorrectFieldList[0]; IEnumerable <GrazingFieldReport> OrderedAnimals = (from animal in CorrectField.animalsList group animal by animal.Type into NewGroup select new GrazingFieldReport { AnimalType = NewGroup.Key, Number = NewGroup.Count().ToString() } ); List <GrazingFieldReport> AnimalList = OrderedAnimals.ToList(); int count = 1; Console.WriteLine(); Console.WriteLine("The following is in the Grazing Field:"); Console.WriteLine(); foreach (GrazingFieldReport animal in AnimalList) { Console.WriteLine($"{count}: {animal.Number} {animal.AnimalType}"); count++; } Console.WriteLine(); Console.WriteLine("Which resource should be processed?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); int correctedChoice = choice - 1; string AnimalType = AnimalList[correctedChoice].AnimalType; Console.WriteLine($"How many {AnimalType} should be processed? (Max 7)"); int amountToProcess = Int32.Parse(Console.ReadLine()); if (amountToProcess > 7) { Console.WriteLine("Learn to read, dumbass"); amountToProcess = Int32.Parse(Console.ReadLine()); } if (amountToProcess <= 7) { farm.ProcessingList.Add(new ToProcess { FacilityId = CorrectField.ShortId, Type = AnimalType, AmountToProcess = amountToProcess }); Console.WriteLine("Ready to process? (Y/n)"); Console.Write("> "); string input = Console.ReadLine(); switch (input) { case "Y": break; case "n": ChooseMeatProcessor.CollectInput(farm); break; default: break; } } }
/* * This method must specify the correct product interface of the * resource being purchased. */ //will be used in the future to add generic resources // public void PurchaseResource<T>(IResource resource, int index) // { // Console.WriteLine(typeof(T).ToString()); // switch (typeof(T).ToString()) // { // case "Cow": // GrazingFields[index].AddResource((IGrazing)resource); // break; // default: // break; // } // } public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); Console.WriteLine($"New field has been created!"); Console.ReadLine(); }
public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); Console.WriteLine("Grazing Field Succesfully Created"); Thread.Sleep(1500); }
public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); // Confirmation System.Console.WriteLine($"{field} has been added"); }
public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); Console.WriteLine("You have added a grazing field!"); }
public void AddGrazingField(GrazingField field) { GrazingFieldList.Add(field); FacilityList.Add(field); }
public void AddGrazingField(GrazingField grazingField) { GrazingFields.Add(grazingField); }
public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); }
public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); AvailableGrazingFields.Add(field); }
/* * This method must specify the correct product interface of the * resource being purchased. */ // public void PurchaseResource<T> (IResource resource, int index) // { // Console.WriteLine(typeof(T).ToString()); // switch (typeof(T).ToString()) // { // case "Cow": // GrazingFields[index].AddResource((IGrazing)resource); // break; // default: // break; // } // } public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); Console.WriteLine("You have added a Grazing Field!"); Thread.Sleep(1000); }
public void AddGrazingField(GrazingField field) { GrazingFields.Add(field); Console.WriteLine("Grazing Field created successfully!"); Console.WriteLine(GrazingFields[GrazingFields.Count - 1]); }