Ejemplo n.º 1
0
 // Adds Plowed field when purchasing new facility
 public void AddPlowedField(PlowedField plowedField)
 {
     PlowedFields.Add(plowedField);
     Console.WriteLine("Plowed Field Added");
     Console.WriteLine("Press enter to return to Main Menu");
     Console.ReadLine();
 }
        public static void CollectInput(Farm farm)
        {
            if (_facilities.Count == 0)
            {
                StandardMessages.ShowMessage("No available fields to process.");
                return;
            }
            do
            {
                // Select a field
                PlowedField selectedField = SelectField();

                // Select a resource type
                var groups = selectedField.CreateGroup();
                IGrouping <string, ISeedProducing> selectedGroup = SelectResourceType(groups);

                // Select quantity of resources to process
                int quantity = SelectQuantity(farm.SeedHarvester.Capacity, selectedGroup);

                // Add selected resources to hopper
                selectedField.SendToHopper(quantity, selectedGroup.Key, farm);
            } while (AddMore(farm.SeedHarvester.Capacity));

            farm.SeedHarvester.Process();

            // if (selectedGroup.Key == "Sunflower")
            // {
            //   farm.SeedHarvester.SunflowerSeeds += ProcessedSeeds;
            // }
            // else if (selectedGroup.Key == "Sesame")
            // {
            //   farm.SeedHarvester.SesameSeeds += ProcessedSeeds;

            // }
        }
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     Console.WriteLine();
     Console.WriteLine($"New Plowed Field Added!");
     System.Threading.Thread.Sleep(3000);
 }
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     Console.WriteLine("Plowed field has been created");
     Console.WriteLine("Press enter key to continue");
     Console.ReadLine();
 }
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     PlantFields.Add(field);
     Console.WriteLine("A new plowed field has been created.");
     Thread.Sleep(2000);
 }
        public static void CollectInput(Farm farm, string seedChoice, int amountChoice)
        {
            Console.Clear();

            PlowedField anyFieldWithRoom = farm.PlowedFields.Find(pf => (pf.MaxCapacity - pf.CurrentCapacity) >= amountChoice);

            if (anyFieldWithRoom != null)
            {
                for (int i = 0; i < farm.PlowedFields.Count; i++)
                {
                    PlowedField currentField = farm.PlowedFields[i];
                    if (currentField.MaxCapacity - currentField.CurrentCapacity >= amountChoice)
                    {
                        Console.WriteLine($"{i + 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()) - 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 <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 Sesame());
                }


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

                /*
                 *  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);
            }
        }
        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 void AddPlowedField(PlowedField field)
 {
     try
     {
         PlowedFields.Add(field);
         //Ticket #30
         Console.WriteLine("A new plowed field has been created!");
         Console.WriteLine("Press enter to continue.");
         Console.ReadLine();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Could not add a plowed field.");
         Console.WriteLine("Press enter to continue.");
         Console.ReadLine();
     }
 }
Ejemplo n.º 9
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);
            });
        }
Ejemplo n.º 10
0
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     Console.WriteLine($"New Plowed Field has been created!");
     Console.ReadLine();
 }
Ejemplo n.º 11
0
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     NaturalAndPlowed.Add(field);
 }
Ejemplo n.º 12
0
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     Console.WriteLine("Plowed Field Succesfully Created");
     Thread.Sleep(1500);
 }
Ejemplo n.º 13
0
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     Console.WriteLine("You have added a Plowed Field!");
     Thread.Sleep(1000);
 }
Ejemplo n.º 14
0
 public void AddPlowedField(PlowedField plowField)
 {
     PlowedFields.Add(plowField);
 }
Ejemplo n.º 15
0
 public void AddPlowedField(PlowedField field)
 {
     PlowedFieldList.Add(field);
     FacilityList.Add(field);
     PlantFacilityList.Add(field);
 }
        public static void CollectInput(Farm farm, IPlant plant)
        {
            Utils.Clear();

            try {
                for (int i = 1; i <= farm.PlowedFields.Count; i++)
                {
                    PlowedField field = farm.PlowedFields[i - 1];
                    if (field.Capacity > field.numOfPlants())
                    {
                        Console.WriteLine($"{i}. Plowed Field {field.shortId()} has {(field.numOfPlants() / 5)} 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}. Plowed 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.PlowedFields[choice - 1].AddResource(plant);
            } catch {
                Console.WriteLine("Please enter a valid selection.");
                Thread.Sleep(1000);
                CollectInput(farm, plant);
            }

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Ejemplo n.º 17
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);
            }
        }
Ejemplo n.º 18
0
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
 }
Ejemplo n.º 19
0
 public void AddPlowedField(PlowedField field)
 {
     PlowedFields.Add(field);
     AvailablePlowedFields.Add(field);
 }