public static void CollectInput(Farm farm, IPlowed plant) { Utils.Clear(); for (int i = 0; i < farm.PlowedFields.Count; i++) { Console.WriteLine($"{i + 1}. Plowed Field"); } Console.WriteLine(); // How can I output the type of plant chosen here? Console.WriteLine($"Place the plant where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); farm.PlowedFields[choice].AddResource(plant); /* * 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, IPlowed plant) { Console.Clear(); Console.WriteLine($"How many {plant} would you like to purchase?"); int input = Int32.Parse(Console.ReadLine()); numberOfPlants.Clear(); for (int i = 0; i < input; i++) { numberOfPlants.Add(plant); } for (int i = 0; i < farm.PlowedFields.Count; i++) { if (farm.PlowedFields[i].Flowers.Count < farm.PlowedFields[i].Capacity) { PlowedField specificField = farm.PlowedFields[i]; Console.WriteLine($"{i + 1}. {specificField}"); } } Console.WriteLine(); // How can I output the type of plant chosen here? Console.WriteLine($"Grow the plant where?"); Console.Write("> "); try { int choice = Int32.Parse(Console.ReadLine()) - 1; farm.PlowedFields[choice].AddResources(numberOfPlants); } 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<IPlowed>(plant, choice); }
public static void CollectInput(Farm farm, IPlowed plant) { Console.Clear(); List <PlowedField> capacityList = farm.PlowedFields.Where(thingy => thingy.NumberOfPlants < thingy.Capacity).ToList(); if (capacityList.Count == 0) { Console.WriteLine("All plowed fields are at capacity or you have not created a plowed field. Please create a new natural field."); Console.WriteLine("Please press enter to return to the main menu."); Console.ReadLine(); return; } else { for (int i = 0; i < capacityList.Count; i++) { if (capacityList[i].NumberOfPlants < capacityList[i].Capacity) { // if the grazing field is not over capacity, display and chose it Console.WriteLine($"Number of plants in plowed field {i + 1}: {capacityList[i].NumberOfPlants}"); } } } Console.WriteLine(); // How can I output the type of animal chosen here? Console.WriteLine($"Plant the seeds where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); Console.WriteLine("You've planted a seed!"); Thread.Sleep(1000); farm.PlowedFields[choice - 1].AddResource(plant); /* * 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, IPlowed seed) { Utils.Clear(); for (int i = 0; i < farm.PlowedFields.Count; i++) { if (farm.PlowedFields[i].seedCount != farm.PlowedFields[i].Capacity) { var sesameCount = 0; var sunflowerCount = 0; Console.WriteLine($"{i + 1}. {farm.PlowedFields[i].ToString()} Max Capacity: {farm.PlowedFields[i].Capacity}"); sesameCount = farm.PlowedFields[i]._seeds .Where(plant => plant.Type == "Sesame") .Count(); Console.WriteLine($"Sesame: {sesameCount}\n"); sunflowerCount = farm.PlowedFields[i]._seeds .Where(plant => plant.Type == "Sunflower") .Count(); Console.WriteLine($"Sunflower: {sunflowerCount}\n"); } } // Console.WriteLine(); // How can I output the type of animal chosen here? Console.WriteLine($"Place the plant where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()) - 1; farm.PlowedFields[choice].AddResource(seed); /* * 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, IPlowed plant) { Console.Clear(); List <IFacility <IPlowed> > openPlowedFields = new List <IFacility <IPlowed> >(); var sortedPlowedFields = farm.PlowedFields.Where(plowedField => (plowedField.Capacity - 1) >= plowedField.CurrentStock()).ToList(); for (int i = 0; i < sortedPlowedFields.Count; i++) { if ((sortedPlowedFields[i].Capacity - 1) >= sortedPlowedFields[i].CurrentStock()) { openPlowedFields.Add(sortedPlowedFields[i]); Console.WriteLine($"{i + 1}. Plowed Field (Current Stock: {sortedPlowedFields[i].CurrentStock()})"); sortedPlowedFields[i].ShowPlantsByType(); } } Console.WriteLine(); if (sortedPlowedFields.Count > 0) { Console.WriteLine($"Place the plant where?"); Console.Write("> "); try { int choice = Int32.Parse(Console.ReadLine()); if (plant is IPlowed) { try { sortedPlowedFields[choice - 1].AddResource(plant); } catch (ArgumentOutOfRangeException) { Console.WriteLine("Invalid option. Please create a new plant and try again."); Thread.Sleep(2000); DisplayBanner(); PurchaseSeed.CollectInput(farm); } } else { Console.WriteLine("There are no matching facilities available. Please create one first."); Thread.Sleep(2000); } } catch (FormatException) { Console.WriteLine("Invalid option. Please create a new plant and try again."); Thread.Sleep(2000); DisplayBanner(); PurchaseSeed.CollectInput(farm); } } // if (openPlowedFields.Count > 0) // { // Console.WriteLine($"Place the plant where?"); // Console.Write("> "); // int choice = Int32.Parse(Console.ReadLine()); // if (plant is IPlowed) // { // sortedPlowedFields[choice - 1].AddResource(plant); // } // else // { // // Console.Clear(); // Console.WriteLine("Please select another facility"); // for (int i = 0; i < farm.PlowedFields.Count; i++) // { // Console.WriteLine($"{i + 1}. Plowed Field"); // } // } // } // else // { // Console.WriteLine("There are no matching facilities available. Please create one first."); // 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); }