public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     Console.WriteLine("Natural Field has been added");
     Console.WriteLine("Press enter key to continue");
     Console.ReadLine();
 }
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     PlantFields.Add(field);
     Console.WriteLine("A new natural field has been created.");
     Thread.Sleep(2000);
 }
Esempio n. 3
0
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     Console.WriteLine("Natural Field Added");
     Console.WriteLine("Press enter to return to Main Menu");
     Console.ReadLine();
 }
        public static void CollectInput(Farm farm, string seedChoice, int amountChoice)
        {
            Console.Clear();

            NaturalField anyFieldWithRoom = farm.NaturalFields.Find(nf => (nf.MaxCapacity - nf.CurrentCapacity) >= amountChoice);

            if (anyFieldWithRoom != null)
            {
                for (int i = 0; i < farm.NaturalFields.Count; i++)
                {
                    NaturalField currentField = farm.NaturalFields[i];
                    if (currentField.MaxCapacity - currentField.CurrentCapacity >= amountChoice)
                    {
                        Console.WriteLine($"{i + 1}. Natural field - {currentField.CurrentCapacity} of {currentField.MaxCapacity} rows of plants\n");
                    }
                }

                Console.WriteLine();

                // How can I output the type of plant chosen here?
                if (UserTriedToSelectAFullFacility)
                {
                    Console.WriteLine("That field does not have enough room.");
                }
                Console.WriteLine($"Place the plants where?");

                Console.Write("> ");
                int choice = Int32.Parse(Console.ReadLine()) - 1;

                //user is buying multiple seeds so we need a list holding however many they want, then adding the list of resources to field which is on the farm

                List <ICompostProducing> plants = new List <ICompostProducing>();

                //determine which type of plant they want and then with for loop adding the appropriate amount(amountChoice parameter) to list of plants

                for (int i = 0; i < amountChoice; i++)
                {
                    plants.Add(new Wildflower());
                }


                //now we're adding the list of plants to the specific field that the user chose from the menu
                farm.NaturalFields[choice].AddResource(farm, plants);

                //make sure that this variable is set to false, in case user was previous directed
                PurchaseSeed.ThereIsNoRoomForTheSeedBeingPurchased = false;

                /*
                 *  Couldn't get this to work. Can you?
                 *  Stretch goal. Only if the app is fully functional.
                 */
                // farm.PurchaseResource<IGrazing>(animal, choice);
            } //else if there isn't room for all the plants the user is trying to add, this else statement notifies user and takes to previous menu
            else
            {
                PurchaseSeed.ThereIsNoRoomForTheSeedBeingPurchased = true;
                Program.DisplayBanner();
                PurchaseSeed.CollectInput(farm);
            }
        }
Esempio n. 5
0
        public static void CollectInput(Farm farm, IPlant plant)
        {
            Utils.Clear();
            try {
                for (int i = 1; i <= farm.NaturalFields.Count; i++)
                {
                    NaturalField field = farm.NaturalFields[i - 1];
                    if (field.Capacity > field.numOfPlants())
                    {
                        Console.WriteLine($"{i}. Natural Field {field.shortId()} has {(field.numOfPlants() / 6)} rows of plants.");

                        // Print out the counts of each type of animal
                        var counts = field.Plants.GroupBy(plant => plant.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}. Natural Field {field.shortId()} is at capacity with {field.numOfPlants()} plants.");
                        // Print out the counts of each type of animal
                        var counts = field.Plants.GroupBy(plant => plant.Type)
                                     .Select(group => new PrintReport {
                            Name  = group.Key,
                            Count = group.Count()
                        });

                        foreach (PrintReport report in counts)
                        {
                            Console.WriteLine($"{report.Name}: {report.Count}");
                        }
                    }
                }

                Console.WriteLine();

                // How can I output the type of seed chosen here?
                Console.WriteLine($"Place the plant where?");

                Console.Write("> ");
                int choice = Int32.Parse(Console.ReadLine());

                farm.NaturalFields[choice - 1].AddResource(plant);
            } catch {
                Console.WriteLine("Please enter a valid selection.");
                Thread.Sleep(1000);
                CollectInput(farm, plant);
            }
        }
Esempio n. 6
0
        public static void CollectInput(Farm farm, INatural 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.NaturalFields.Count; i++)
            {
                if (farm.NaturalFields[i].Flowers.Count < farm.NaturalFields[i].Capacity)
                {
                    NaturalField specificField = farm.NaturalFields[i];
                    Console.WriteLine($"{i + 1}. {specificField}");
                }
            }

            Console.WriteLine();

            Console.WriteLine($"Where would you like to plant the {plant}?");

            Console.Write("> ");
            try
            {
                int choice = Int32.Parse(Console.ReadLine()) - 1;
                farm.NaturalFields[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<INatural>(plant, choice);
        }
 public void AddNaturalField(NaturalField field)
 {
     try
     {
         NaturalFields.Add(field);
         //Ticket #29
         Console.WriteLine("A new natural field has been created!");
         Console.WriteLine("Press enter to continue.");
         Console.ReadLine();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Could not add a natural field.");
         Console.WriteLine("Press enter to continue.");
         Console.ReadLine();
     }
 }
Esempio n. 8
0
        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);
            });
        }
Esempio n. 9
0
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     AvailableNaturalFields.Add(field);
 }
Esempio n. 10
0
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
 }
Esempio n. 11
0
 public void AddNaturalField(NaturalField naturalField)
 {
     NaturalFields.Add(naturalField);
 }
Esempio n. 12
0
 public void AddNaturalField(NaturalField plant)
 {
     NaturalFields.Add(plant);
 }
Esempio n. 13
0
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     Console.WriteLine($"New Natural Field has been created!");
     Console.ReadLine();
 }
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     NaturalAndPlowed.Add(field);
 }
Esempio n. 15
0
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     Console.WriteLine("Natural Field successfully created");
     Thread.Sleep(1500);
 }
Esempio n. 16
0
        public static void CollectInput(Farm farm, string seedChoice, int amountChoice)
        {
            Console.Clear();

            //     //anything that is of type object can be put in this list
            //     List<object> sunflowerFields = new List<object>();

            //     farm.PlowedFields.ForEach(pf => {

            //     //cast from type PlowedField to type object
            //     object transformedField = pf as object;
            //     sunflowerFields.Add(transformedField);
            //     });

            //   farm.NaturalFields.ForEach(nf => {

            //     //cast from type PlowedField to type object
            //     object transformedField = nf as object;
            //     sunflowerFields.Add(transformedField);
            //     });



            NaturalField anyNaturalFieldWithRoom = farm.NaturalFields.Find(nf => (nf.MaxCapacity - nf.CurrentCapacity) >= amountChoice);
            PlowedField  anyPlowedFieldWithRoom  = farm.PlowedFields.Find(pf => (pf.MaxCapacity - pf.CurrentCapacity) >= amountChoice);

            if (anyNaturalFieldWithRoom != null || anyPlowedFieldWithRoom != null)
            {
                for (int i = 0; i < farm.NaturalFields.Count; i++)
                {
                    NaturalField currentField = farm.NaturalFields[i];
                    if (currentField.MaxCapacity - currentField.CurrentCapacity >= amountChoice)
                    {
                        Console.WriteLine($"{i + 1}. Natural field - {currentField.CurrentCapacity} of {currentField.MaxCapacity} rows of plants\n");
                    }
                }

                for (int i = 0; i < farm.PlowedFields.Count; i++)
                {
                    PlowedField currentField = farm.PlowedFields[i];
                    //this allows the plowed fields to be displayed after the available natural fields
                    if (currentField.MaxCapacity - currentField.CurrentCapacity >= amountChoice)
                    {
                        Console.WriteLine($"{i + farm.NaturalFields.Count + 1}. Plowed field - {currentField.CurrentCapacity} of {currentField.MaxCapacity} rows of plants\n");
                    }
                }

                Console.WriteLine();

                // How can I output the type of plant chosen here?
                if (UserTriedToSelectAFullFacility)
                {
                    Console.WriteLine("That field does not have enough room.");
                }
                Console.WriteLine($"Place the plants where?");

                Console.Write("> ");
                int choice = Int32.Parse(Console.ReadLine());

                //user is buying multiple seeds so we need a list holding however many they want, then adding the list of resources to field which is on the farm

                //if their choice is a number greater than Natural Fields count, then they are choosing a plowed field
                if (choice > farm.NaturalFields.Count)
                {
                    List <ISeedProducing> plants = new List <ISeedProducing>();

                    //determine which type of plant they want and then with for loop adding the appropriate amount(amountChoice parameter) to list of plants

                    for (int i = 0; i < amountChoice; i++)
                    {
                        plants.Add(new Sunflower());
                    }



                    //now we're adding the list of plants to the specific field that the user chose from the menu
                    //choice(user input) - farm.NaturalFields.Count (number of natural fields listed) - 1 (bc index starts from 0 not 1)
                    PlowedField target = farm.PlowedFields[choice - farm.NaturalFields.Count - 1];

                    if (target.MaxCapacity - target.CurrentCapacity >= amountChoice)
                    {
                        farm.PlowedFields[choice - 1 - farm.NaturalFields.Count].AddResource(farm, plants);
                        ChooseSunflowerField.UserTriedToSelectAFullFacility = false;
                    }
                    else
                    {
                        UserTriedToSelectAFullFacility = true;
                        ChooseSunflowerField.CollectInput(farm, seedChoice, amountChoice);
                    }

                    //make sure that this variable is set to false, in case user was previous directed
                    PurchaseSeed.ThereIsNoRoomForTheSeedBeingPurchased = false;
                }
                else
                {
                    List <ICompostProducing> plants = new List <ICompostProducing>();

                    //determine which type of plant they want and then with for loop adding the appropriate amount(amountChoice parameter) to list of plants

                    NaturalField target = farm.NaturalFields[choice - 1];
                    if (target.MaxCapacity - target.CurrentCapacity >= amountChoice)
                    {
                        for (int i = 0; i < amountChoice; i++)
                        {
                            plants.Add(new Sunflower());
                        }



                        //now we're adding the list of plants to the specific field that the user chose from the menu
                        //choice(user input) - 1 (bc index starts from 0 not 1)
                        target.AddResource(farm, plants);

                        //make sure that this variable is set to false, in case user was previous directed
                        PurchaseSeed.ThereIsNoRoomForTheSeedBeingPurchased = false;
                        UserTriedToSelectAFullFacility = false;
                    }
                    else
                    {
                        UserTriedToSelectAFullFacility = true;
                        ChooseSunflowerField.CollectInput(farm, seedChoice, amountChoice);
                    }
                }

                /*
                 *  Couldn't get this to work. Can you?
                 *  Stretch goal. Only if the app is fully functional.
                 */
                // farm.PurchaseResource<IGrazing>(animal, choice);
            } //else if there isn't room for all the plants the user is trying to add, this else statement notifies user and takes to previous menu
            else
            {
                PurchaseSeed.ThereIsNoRoomForTheSeedBeingPurchased = true;
                Program.DisplayBanner();
                PurchaseSeed.CollectInput(farm);
            }
        }
Esempio n. 17
0
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     Console.WriteLine("You have added a Natural field!");
 }
        public static void ListResources(Farm farm, string id, string type, int alreadyProcessedSunflowers)
        {
            IEnumerable<NaturalField> CorrectFieldEnumerable = from field in farm.NaturalFields
                                                               where field.ShortId == id
                                                               select field;

            List<NaturalField> CorrectFieldList = CorrectFieldEnumerable.ToList();

            NaturalField CorrectField = CorrectFieldList[0];

            IEnumerable<NaturalFieldReport> OrderedFlowers = (from flower in CorrectField.plantsList
                                                              group flower by flower.Type into NewGroup
                                                              select new NaturalFieldReport
                                                              {
                                                                  PlantType = NewGroup.Key,
                                                                  Number = NewGroup.Count().ToString()
                                                              }
                );

            IEnumerable<NaturalFieldReport> JustSunflowers = from flower in OrderedFlowers
                                                             where flower.PlantType == "Sunflower"
                                                             select flower;

            List<NaturalFieldReport> OrderedSunflowersList = JustSunflowers.ToList();

            int count = 1;

            int numberToCheckSunflower = 0;

            Console.WriteLine();
            Console.WriteLine("The following flowers can be processed in the Natural Field");
            Console.WriteLine();
            foreach (NaturalFieldReport flower in JustSunflowers)
            {
                numberToCheckSunflower = Int32.Parse(flower.Number) - alreadyProcessedSunflowers;
                Console.WriteLine($"{count}: {numberToCheckSunflower} {flower.PlantType}");
                count++;
            }

            Console.WriteLine();
            Console.WriteLine("Which resource should be processed?");
            Console.Write("> ");
            int choice = Int32.Parse(Console.ReadLine());
            int correctedChoice = choice - 1;

            string PlantType = OrderedSunflowersList[correctedChoice].PlantType;

            Console.WriteLine($"How many {PlantType} should be processed? (Max 5)");
            int amountToProcess = Int32.Parse(Console.ReadLine());

            while (amountToProcess > 5)
            {
                Console.WriteLine("Yo I can't process that much at once, dumbass");
                amountToProcess = Int32.Parse(Console.ReadLine());
            }
            while (amountToProcess > numberToCheckSunflower)
            {
                Console.WriteLine("Yo there aren't that many to process, dumbass");
                amountToProcess = Int32.Parse(Console.ReadLine());
            }

            farm.ProcessingList.Add(new ToProcess
            {
                FacilityId = CorrectField.ShortId,
                Type = PlantType,
                AmountToProcess = amountToProcess
            });

            Console.WriteLine("Ready to process? (Y/n)");
            Console.Write("> ");
            string input = Console.ReadLine();

            switch (input)
            {
                case "Y":
                    break;
                case "n":
                    ChooseSeedHarvester.CollectInput(farm);
                    break;
                default:
                    break;
            }
        }
Esempio n. 19
0
 public void AddNaturalField(NaturalField naturalField)
 {
     NaturalFieldList.Add(naturalField);
     FacilityList.Add(naturalField);
     PlantFacilityList.Add(naturalField);
 }
Esempio n. 20
0
 public void AddNaturalField(NaturalField field)
 {
     NaturalFields.Add(field);
     // Confirmation
     System.Console.WriteLine($"{field} has been added");
 }