public static void CollectInput(List <GrazingField> field, IGrazing animal)
        {
            Console.Clear();

            for (int i = 0; i < field.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field: {field[i].Name} ({field[i].NumAnimals} animals)");
            }

            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());

                field[choice - 1].AddResource(animal);
            }
            catch (Exception)
            {
                Program.ShowMessage("Invalid Input");
            }
        }
Example #2
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();


            //This displays all grazing fields after purchasing animals
            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                //Grazing field is an array.  + 1 will stop the list from starting at zero.
                Console.WriteLine($"{i + 1}. Grazing Field : Contains {farm.GrazingFields[i].animals.Count} Animals with {farm.GrazingFields[i].Capacity - farm.GrazingFields[i].animals.Count} Available Spots");
            }

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

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

            //-1 will set the choice back to the GrazinFields actual array index not the displayed "list" value.4

            farm.GrazingFields[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);
        }
Example #3
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();

            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field");
            }

            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.GrazingFields[choice].AddResource(animal);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #4
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();
            var filterGrazingField = farm.GrazingFields.Where(field => field.IsSpaceAvailable() > 0).ToList();

            for (int i = 0; i < filterGrazingField.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field ({filterGrazingField[i].AnimalsInFacility()} Animal(s) in the fields)");
                filterGrazingField[i].AnimalGroups();
            }

            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());

            filterGrazingField[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, IGrazing animal)
        {
            Utils.Clear();

            Console.WriteLine("List of grazing fields: ");

            List <GrazingField> AvailableGrazing = farm.GrazingFields.Where(field => field.Availability > 0).ToList();

            for (int i = 0; i < AvailableGrazing.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field({AvailableGrazing[i].ShortId}), currently contains {AvailableGrazing[i].AnimalCount} animals.");
            }

            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()) - 1;

            AvailableGrazing[choice].AddResource(animal);
            Console.WriteLine(AvailableGrazing[choice]);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #6
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            while (!_isFull)
            {
                Utils.Clear();
                break;
            }

            Console.WriteLine("CHOOSING FACILITY...");
            Console.WriteLine();
            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field ({farm.GrazingFields[i].AnimalCount} animals)");
            }

            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());

            choice--;

            CheckForFullField(choice, farm, 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, IGrazing animal)
        {
            Console.Clear();


            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field ");
            }

            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());

            //choice must be subtracted by 1 in order to select the proper index in the array.
            farm.GrazingFields[choice - 1].AddResource(animal);

            Console.WriteLine();
            Console.WriteLine("Press return key to go back to main menu.");
            Console.WriteLine("\n\n\n");
            Console.ReadLine();

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #8
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            foreach (GrazingField field in farm.GrazingFields)
            {
                if (field.Animals.Count < field.Capacity)
                {
                    StringBuilder output = new StringBuilder();
                    output.Append($"{farm.GrazingFields.IndexOf(field)+1}. Grazing Field (");
                    if (field.Animals.Count == 0)
                    {
                        output.Append("0");
                    }
                    else
                    {
                        //group by
                        List <TypeCounter> animalCount = (
                            from ruminant in field.Animals
                            group ruminant by ruminant.Type into AnimalGroup
                            select new TypeCounter {
                            Type = AnimalGroup.Key,
                            Count = AnimalGroup.Count()
                        }
                            ).ToList();
                        foreach (TypeCounter entry in animalCount)
                        {
                            // TODO: remove trailing comma
                            output.Append($"{entry.Count} {entry.Type},");
                        }
                    }
                    output.Append($" of {field.Capacity} animals)");
                    Console.WriteLine(output);
                }
            }
            // STRETCH: realign numbers for facility listing when it skips full ones
            // put available fields in a new temporary List<>? then foreach the list?
            // use linq directives to pull available fields?

            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());

            try {
                farm.GrazingFields[choice - 1].AddResource(farm, animal);
            } catch (ArgumentOutOfRangeException) {
                Console.WriteLine($"Invalid option: {choice}");
                Console.WriteLine("Press any key to go back to main menu.");
                Console.ReadLine();
            }

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #9
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();
            if (farm.AvailableGrazingFields.Count() == 0)
            {
                Console.WriteLine("You need to create a Grazing Field before you can purchase an animal.");
            }

            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                if (farm.GrazingFields[i].GetCount() < farm.GrazingFields[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Grazing Field ({farm.GrazingFields[i].GetCount()} animals)");
                    farm.GrazingFields[i].GroupAnimals();
                }
            }

            Console.WriteLine();

            // How can I output the type of animal chosen here?
            try
            {
                if (farm.AvailableGrazingFields.Count() != 0)
                {
                    Console.WriteLine($"Place the animal where?");
                    Console.Write("> ");
                    int choice = Int32.Parse(Console.ReadLine());
                    if (farm.GrazingFields[choice - 1].GetCount() < farm.GrazingFields[choice - 1].Capacity)
                    {
                        farm.GrazingFields[choice - 1].AddResource(animal);
                        if (farm.GrazingFields[choice - 1].GetCount() >= farm.GrazingFields[choice - 1].Capacity)
                        {
                            farm.AvailableGrazingFields.Remove(farm.GrazingFields[choice - 1]);
                        }
                        Console.WriteLine("Animal Added To Grazing Field");
                    }
                }
            }
            catch (System.FormatException)
            {
                Console.WriteLine($"Invalid option");
                Console.WriteLine();
            }
            catch (System.ArgumentOutOfRangeException)
            {
                Console.WriteLine($"Invalid Number");
                Console.WriteLine();
            }



            /*
             *  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, IGrazing animal)
        {
            Utils.Clear();

            var availableGrazingFields = farm.GrazingFields.Where(grazingField => grazingField.Animals.Count < grazingField.Capacity).ToList();

            if (availableGrazingFields.Count == 0)
            {
                Console.WriteLine("There are no available grazing fields. \nPress return to go back to the main menu");
                Console.ReadLine();
            }
            else
            {
                for (int i = 0; i < availableGrazingFields.Count; i++)
                {
                    Console.Write($"{i + 1}. Grazing Field {availableGrazingFields[i].AnimalCount()} ");
                    availableGrazingFields[i].AnimalTypeCount();
                    Console.WriteLine();
                }

                Console.WriteLine();

                // How can I output the type of animal chosen here?

                while (true)
                {
                    Console.WriteLine($"Place the animal where? Or hit return to exit");
                    Console.Write("> ");
                    try
                    {
                        var choice = Console.ReadLine();
                        if (String.IsNullOrEmpty(choice))
                        {
                            break;
                        }
                        else
                        {
                            availableGrazingFields[Int32.Parse(choice) - 1].AddResource(animal);
                            break;
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Please enter a valid index range");
                    }
                }
            }



            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #11
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();

            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                if (farm.GrazingFields[i].AnimalCount() < farm.GrazingFields[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Grazing Field");
                    Console.WriteLine($"\t This field has {farm.GrazingFields[i].AnimalCount()} animals currently!\n");
                    var CowCount = 0;
                    CowCount = farm.GrazingFields[i].AnimalList()
                               .Where(animalType => animalType.Type == "Cow")
                               .Count();
                    Console.WriteLine($"\t \t There are {CowCount} Cows!");
                    var GoatCount = 0;
                    GoatCount = farm.GrazingFields[i].AnimalList()
                                .Where(animalType => animalType.Type == "Goat")
                                .Count();
                    Console.WriteLine($"\t \t There are {GoatCount} Goats!");
                    var PigCount = 0;
                    PigCount = farm.GrazingFields[i].AnimalList()
                               .Where(animalType => animalType.Type == "Pig")
                               .Count();
                    Console.WriteLine($"\t \t There are {PigCount} Pigs!");
                    var SheepCount = 0;
                    SheepCount = farm.GrazingFields[i].AnimalList()
                                 .Where(animalType => animalType.Type == "Sheep")
                                 .Count();
                    Console.WriteLine($"\t \t There are {SheepCount} Sheep!");
                    var OstrichCount = 0;
                    OstrichCount = farm.GrazingFields[i].AnimalList()
                                   .Where(animalType => animalType.Type == "Ostrich")
                                   .Count();
                    Console.WriteLine($"\t \t There are {OstrichCount} Ostriches!");
                }
            }

            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.GrazingFields[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, IGrazing animal)
        {
            Console.Clear();
            List <GrazingField> capacityList = farm.GrazingFields.Where(thingy => thingy.NumberOfAnimals < thingy.Capacity).ToList();



            if (capacityList.Count == 0)
            {
                Console.WriteLine("All grazing fields are at capacity or you have not created a grazing field. Please create a new grazing 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].NumberOfAnimals < capacityList[i].Capacity)
                    {
                        // if the grazing field is not over capacity, display and chose it
                        Console.WriteLine($" Grazing field #{i + 1} has: ");
                        Console.WriteLine($"{capacityList[i].cows} Cows");
                        Console.WriteLine($"{capacityList[i].sheep} Sheep");
                        Console.WriteLine($"{capacityList[i].goats} Goats");
                        Console.WriteLine($"{capacityList[i].ostriches} Ostriches");
                        Console.WriteLine($"{capacityList[i].pigs} Pigs");
                        Console.WriteLine("- - - - - - - - - - - - - - - - - - - ");
                    }
                }
            }

            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());

            Console.WriteLine("Congrats on buying a new animal!");
            Thread.Sleep(1000);

            // if(id.ToString() == "1"){

            // }
            capacityList[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);
        }
Example #13
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();
            /*Creating a bool for breaking the while loop*/
            bool Placed = false;

            while (Placed == false)
            {
                /*Loop for printing fields with if for seeing if full*/
                for (int i = 0; i < farm.GrazingFields.Count; i++)
                {
                    Console.WriteLine(farm.GrazingFields[i].Capacity == farm.GrazingFields[i].currentNumberInField
                        ? $"{i + 1}. Grazing Field (Full)"
                        : $"{i + 1}. Grazing Field ({farm.GrazingFields[i].currentNumberInField} animals)");
                }

                Console.WriteLine();

                /*Asking where to place the animal by type/name i.e. cow*/
                Console.WriteLine($"Place the {animal.GetType().Name} where?");

                Console.Write("> ");
                /*Need to add try to this for error handling*/
                try
                {
                    int choice = Int32.Parse(Console.ReadLine());
                    /*Checking to see if the field has room for the animal*/
                    if (farm.GrazingFields[choice - 1].currentNumberInField == farm.GrazingFields[choice - 1].Capacity)
                    {
                        Console.WriteLine("**** That facility is not large enough ****");
                        Console.WriteLine("****     Please choose another one      ****");
                        choice = Int32.Parse(Console.ReadLine());
                    }
                    /*If so adding to the field*/
                    else
                    {
                        farm.GrazingFields[choice - 1].AddResource(animal);
                        Placed = true;
                        Console.WriteLine("Break Point");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please enter only numbers");
                }
            }


            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #14
0
        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);
            }
        }
Example #15
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();

            if (farm.GrazingFields.Count == 0)
            {
                Console.WriteLine("No grazing fields available. Buy a grazing field! Press any key to continue");
                Console.Write("> ");
                Console.ReadLine();
            }
            else
            {
                for (int i = 0; i < farm.GrazingFields.Count; i++)
                {
                    Console.WriteLine($"{i + 1}. Grazing Field currently contains {farm.GrazingFields[i].AnimalCount()} animal(s). The capacity is {farm.GrazingFields[i].Capacity} animals");
                    farm.GrazingFields[i].GetAnimalTypes();
                    Console.WriteLine();
                }

                Console.WriteLine();
                Console.WriteLine($"Place the animal where?");

                Console.Write("> ");
                var choice = 0;
                while (!int.TryParse(Console.ReadLine(), out choice))
                {
                    Console.WriteLine("That was invalid. Enter a valid selection.");
                }
                // int choice = Int32.Parse(Console.ReadLine()) - 1;

                if (choice > farm.GrazingFields.Count)
                {
                    Console.WriteLine("Incorrect Selection. Press any key to continue");
                    Console.Write("> ");
                    Console.ReadLine();
                }
                else
                {
                    if (farm.GrazingFields[choice - 1].Capacity == farm.GrazingFields[choice - 1].AnimalCount())
                    {
                        Console.WriteLine("Too many animals. Press any key to continue");
                        Console.Write("> ");
                        Console.ReadLine();
                    }
                    else
                    {
                        farm.GrazingFields[choice - 1].AddResource(animal);
                        Console.WriteLine($"Your Animal was placed in the Grazing Field ! Press any key to continue");
                        Console.ReadLine();
                    }
                }
            }
        }
Example #16
0
        public static void CollectInput(Farm farm, IGrazing animal, bool clear = true)
        {
            if (clear)
            {
                Console.Clear();
            }



            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field ({farm.GrazingFields[i].AnimalCount} {(farm.GrazingFields[i].AnimalCount == 1 ? "animal" : "animals")})");
            }

            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());

            choice = choice - 1;

            int currentListCount        = farm.GrazingFields[choice].AnimalCount;
            int availableSpace          = Convert.ToInt32(farm.GrazingFields[choice].Capacity) - currentListCount;
            int evaluatedAvailableSpace = Math.Sign(availableSpace);

            if (evaluatedAvailableSpace == 1)
            {
                farm.GrazingFields[choice].AddResource(animal);
            }
            else
            {
                Console.Clear();
                Console.WriteLine();
                Console.WriteLine(@"**** That facililty is not large enough ****
****     Please choose another one      ****");
                Console.WriteLine();
                ChooseGrazingField.CollectInput(farm, animal, false);
            }



            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #17
0
        // Collecting the added Grazing Fields
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();
            Console.WriteLine();
            Console.WriteLine(@"
        +-++-++-++-++-++-++-++-++-++-++-++-++-+
        |T||r||e||s||t||l||e||b||r||i||d||g||e|
        +-++-++-++-++-++-++-++-++-++-++-++-++-+
                    |F||a||r||m||s|
                    +-++-++-++-++-+");
            Console.WriteLine();

            // Loop throughh created Facilities and list them by number
            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field");
            }

            Console.WriteLine();

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

            Console.Write("> ");
            // User Inputted number
            int choice = Int32.Parse(Console.ReadLine());

            // Using the Inputted Number in association with the Facility and adding animal
            if (choice > 0 && choice < 21)
            {
                farm.GrazingFields[choice - 1].AddResource(animal);
            }
            // else if (choice == "")
            // {
            //     Console.WriteLine();
            //     Console.WriteLine("Returning to Menu...");
            // }
            else
            {
                Console.WriteLine();
                Console.WriteLine("Value not recognized, press return to exit.");
                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 static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();
            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field has {farm.GrazingFields[i]._animals.Count} grazing animals");
                var animalreport = from grazinganimal in farm.GrazingFields[i]._animals
                                   group grazinganimal by grazinganimal.Type into animalgroup
                                   select  new Dictionary <string, int>()
                {
                    { animalgroup.Key, animalgroup.Count() }
                };
                Console.WriteLine();
                foreach (Dictionary <string, int> grazinganimal in animalreport)
                {
                    foreach (KeyValuePair <string, int> animalgroup in grazinganimal)
                    {
                        Console.WriteLine($"This field has {animalgroup.Value} {animalgroup.Key}s");
                    }
                }
            }
            ;



            // To show the number of grazing fields

            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.GrazingFields[choice - 1].AddResource(animal);

            /*
             *
             *  // foreach (IGrazing grazingAnimal in farm.GrazingFields[i]._animals)
             *  // {
             *
             *  //     Console.WriteLine(grazingAnimal);
             *  // };
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #19
0
        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);
        }
Example #20
0
        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 CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();

            List <GrazingField> availableGrazingFields = new List <GrazingField>();

            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                if ((farm.GrazingFields[i].Capacity) > farm.GrazingFields[i].GetGrazingAnimalCount())
                {
                    availableGrazingFields.Add(farm.GrazingFields[i]);
                }
            }

            int grazingFieldCount = 1;

            if (availableGrazingFields.Count == 0)
            {
                Console.WriteLine("You do not currently have any houses with enough capacity to add this animal. Please add a new facility. Press ENTER to continue.");
                Console.ReadLine();
            }

            for (int i = 0; i < availableGrazingFields.Count; i++)

            {
                while (grazingFieldCount > 0)
                {
                    // How can I output the type of animal chosen here?
                    Console.WriteLine($"{i + 1}: This grazing field currently has {availableGrazingFields[i].GetGrazingAnimalCount()} animal(s) in stock with a capacity of {availableGrazingFields[i].Capacity} animals.");
                    availableGrazingFields[i].getCows();
                    availableGrazingFields[i].getGoats();
                    availableGrazingFields[i].getOstriches();
                    availableGrazingFields[i].getPigs();
                    availableGrazingFields[i].getSheep();
                    Console.WriteLine($"Enter house number to send animal");
                    Console.Write("> ");
                    int choice     = Int32.Parse(Console.ReadLine());
                    int realChoice = choice - 1;
                    availableGrazingFields[realChoice].AddResource(animal);
                    Console.WriteLine($"An animal has been added to the field. You currently have {availableGrazingFields[realChoice].GetGrazingAnimalCount()} animal(s) in this pasture. Press the 'Enter' key to continue.");
                    grazingFieldCount--;
                    Console.ReadLine();
                }
            }
        }
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            // Console.Clear();
            List <GrazingField> OpenGrazingFields = new List <GrazingField>();

            foreach (GrazingField grazingField in farm.GrazingFields)
            {
                if (grazingField.Animals.Count < grazingField.Capacity)
                {
                    OpenGrazingFields.Add(grazingField);
                }
            }

            for (int i = 0; i < OpenGrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field ({OpenGrazingFields[i].Animals.Count} animals - {OpenGrazingFields[i].Cows()} cow, {OpenGrazingFields[i].Pigs()} pig, {OpenGrazingFields[i].Goats()} goat, {OpenGrazingFields[i].Ostriches()} ostrich, {OpenGrazingFields[i].Sheep()} sheep) ");
            }

            Console.WriteLine();

            // How can I output the type of animal chosen here?
            Console.WriteLine($"Place {animal.Type.ToLower()} where?");

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

            try
            {
                if (OpenGrazingFields[choice - 1].Animals.Count < OpenGrazingFields[choice - 1].Capacity)
                {
                    OpenGrazingFields[choice - 1].AddResource(animal);
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                Console.WriteLine($"{choice} is not a valid option");
            }

            /*
             *  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, IGrazing animal)
        {
            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                foreach (var field in farm.GrazingFields)
                {
                    Console.WriteLine($"{1 + i++}. Grazing Field, currently has {field.Capacity - field.CurrentCapacity} animals");
                    if (field._animals.Count > 0)
                    {
                        foreach (var singleAnimal in field._animals.GroupBy(a => a.GetType().Name))
                        {
                            Console.Write($" - Contains {singleAnimal.Count()} {singleAnimal.Key}");
                            if (singleAnimal.Count() > 1)
                            {
                                Console.Write("s" + "\n");
                            }
                            else
                            {
                                Console.Write("\n");
                            }
                        }
                    }
                }
            }

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

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

            if (farm.GrazingFields[choice - 1].CurrentCapacity > 0)
            {
                farm.GrazingFields[choice - 1].AddResource(animal);
            }
            else
            {
                Console.WriteLine("This grazing field is full.");
            }
        }
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();
            //For Loop, loops through entire GrazingField List
            for (int i = 0; i < farm.GrazingFieldList.Count; i++)
            {
                {   //Loops through ever individual field in GrazingFieldList
                    //Individual fields are stored in the variable grazingField
                    var grazingField = farm.GrazingFieldList[i];
                    //If the logic of checkCapacity boolean method is true the field is shown
                    if (grazingField.checkCapacity(farm) == true)
                    {
                        Console.WriteLine($"{i + 1}. Grazing Field");
                        grazingField.listResources();
                    }
                    Hashtable ht = new Hashtable();
                }
            }

            Console.WriteLine();

            // How can I output the type of animal chosen here?
            Console.WriteLine($"Place the {animal.GetType().Name.ToLower()} where?");

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

            //Index had to subtracted. The reason is because the input does not actually
            //equal the index position of the field
            choice = choice - 1;

            farm.GrazingFieldList[choice].AddAnimalResource(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, IGrazing animal)
        {
            Console.Clear();
            List <GrazingField> CapacityList = farm.GrazingFields.Where(thing => thing.GetCount < thing.Capacity).ToList();

            if (CapacityList.Count == 0)
            {
                Console.WriteLine(" All Fields are at Capacity");
                Console.WriteLine("Press return key to return to Main Menu");
                Console.ReadLine();
                return;
            }
            else
            {
                for (int i = 0; i < CapacityList.Count; i++)
                {
                    if (CapacityList[i].GetCount < farm.GrazingFields[i].Capacity)
                    {
                        Console.WriteLine($"Grazing Field: {i + 1}");
                    }
                    Console.WriteLine($"Grazing Field ({CapacityList[i].Animals.Count} Total Animals - {CapacityList[i].Cows()} cow, {CapacityList[i].Pig()} pig, {CapacityList[i].Goat()} goat, {CapacityList[i].Ostrich()} ostrich, {CapacityList[i].Sheep()} sheep) ");
                    Console.WriteLine();
                }
            }
            Console.WriteLine();

            Console.WriteLine();
            // How can I output the type of animal chosen here?
            Console.WriteLine($"Place the animal where?");
            int choice = Int32.Parse(Console.ReadLine());

            CapacityList[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);
        }
Example #26
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();
            List <GrazingField> maxGrazingList = farm.GrazingFields.Where(field => field.Capacity < field.MaxCapacity).ToList();

            for (int i = 0; i < maxGrazingList.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field {maxGrazingList[i].Capacity}");
            }

            Console.WriteLine();

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

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

            choice--;
            ChosenFacility(choice, animal, maxGrazingList);
        }
Example #27
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();
            Console.WriteLine();
            Console.WriteLine(@"
        +-++-++-++-++-++-++-++-++-++-++-++-++-+
        |T||r||e||s||t||l||e||b||r||i||d||g||e|
        +-++-++-++-++-++-++-++-++-++-++-++-++-+
                    |F||a||r||m||s|
                    +-++-++-++-++-+");
            Console.WriteLine();

            // Loop throughh created Facilities and list them by number
            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("> ");
            // User Inputted number
            int choice = Int32.Parse(Console.ReadLine());

            // Using the Inputted Number in association with the Facility and adding animal

            farm.ChickenHouses[choice - 1].AddResource(animal);

            //   Console.WriteLine(farm.ChickenHouses[choice]);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #28
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Utils.Clear();

            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                if (farm.GrazingFields[i].GetTotal() < farm.GrazingFields[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Grazing Field ({farm.GrazingFields[i].GetTotal()} animals)");
                    Console.WriteLine($"{farm.GrazingFields[i].OstrichCount()} Ostriches");
                    Console.WriteLine($"{farm.GrazingFields[i].CowCount()} Cows");
                    Console.WriteLine($"{farm.GrazingFields[i].GoatCount()} Goats");
                    Console.WriteLine($"{farm.GrazingFields[i].PigCount()} Pigs");
                    Console.WriteLine($"{farm.GrazingFields[i].SheepCount()} Sheep");
                }
            }

            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.GrazingFields[choice - 1].AddResource(animal);

            //  if (farm.GrazingFields[choice -1].GetTotal() < farm.GrazingFields[choice - 1].Capacity)
            // {
            //     farm.GrazingFields[choice - 1].AddResource(animal);
            // }
            //     else
            //     {
            //         Console.WriteLine("This field is full.");
            //         Thread.Sleep(2000);
            //     }
        }
Example #29
0
        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);
        }
Example #30
0
        public static void CheckForFullField(int index, Farm farm, IGrazing animal)
        {
            int choice = index + 1;

            if (farm.GrazingFields[index].AnimalCount == farm.GrazingFields[index].Capacity)
            {
                _isFull = true;
                Console.WriteLine("This facility is full.");
                Thread.Sleep(750);
                Console.WriteLine("Please choose another facility.");
                Console.WriteLine();
                Console.WriteLine();
                Thread.Sleep(1500);
                CollectInput(farm, animal);
            }
            else
            {
                Console.Write($"Adding animal to option {choice}");
                Utils.Loading();
                Console.WriteLine("Added animal.");
                farm.GrazingFields[index].AddResource(animal);
            }
        }