コード例 #1
0
 //Adds Duck House field when creating new facility.
 public void AddDuckHouse(DuckHouse house)
 {
     DuckHouses.Add(house);
     Console.WriteLine("Duck House Added");
     Console.WriteLine("Press enter to return to Main Menu");
     Console.ReadLine();
 }
コード例 #2
0
 public void AddDuckHouse(DuckHouse field)
 {
     DuckHouses.Add(field);
     Console.WriteLine("Duck House has been added");
     Console.WriteLine("Press enter key to continue");
     Console.ReadLine();
 }
コード例 #3
0
        public override string ToString()
        {
            StringBuilder report = new StringBuilder();

            GrazingFields.ForEach(gf => report.Append(gf));
            PlowedFields.ForEach(pf => report.Append(pf));
            NaturalFields.ForEach(nf => report.Append(nf));
            DuckHouse.ForEach(dh => report.Append(dh));
            ChickenHouse.ForEach(ch => report.Append(ch));

            return(report.ToString());
        }
コード例 #4
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);
            });
        }
        public static void CollectInput(Farm farm, Duck duck)
        {
            Console.Clear();

            DuckHouse anyHouseWithRoom = farm.DuckHouses.Find(dh => dh.CurrentCapacity < dh.MaxCapacity);

            if (anyHouseWithRoom != null)
            {
                for (int i = 0; i < farm.DuckHouses.Count; i++)
                {
                    DuckHouse currentHouse = farm.DuckHouses[i];
                    if (currentHouse.CurrentCapacity < currentHouse.MaxCapacity)
                    {
                        Console.WriteLine($"{i + 1}. {currentHouse}");
                    }
                }

                Console.WriteLine();

                // How can I output the type of plant chosen here?
                if (UserTriedToSelectAFullFacility)
                {
                    Console.WriteLine("That facility is already full.");
                }
                Console.WriteLine($"Place the duck where?");

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

                farm.DuckHouses[choice].AddResource(farm, duck);
            }
            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);
        }
コード例 #6
0
        public static void CollectInput(Farm farm, IHousing animal)
        {
            Console.Clear();

            for (int i = 0; i < farm.DuckHouses.Count; i++)
            {
                DuckHouse house = farm.DuckHouses[i];
                if (house.Capacity > 0)
                {
                    Console.WriteLine($"{i + 1}. Duck House");
                    Console.Write($"Current animals: {house.GetList().Count}");
                    Console.WriteLine();
                }
            }


            if (farm.DuckHouses.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.DuckHouses[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);
        }
コード例 #7
0
        public static void CollectInput(Farm farm, IResource animal)
        {
            Console.Clear();

            for (int i = 0; i < farm.DuckHouses.Count; i++)
            {
                if (farm.DuckHouses[i].Ducks.Count < farm.DuckHouses[i].Capacity)
                {
                    DuckHouse specificHouse = farm.DuckHouses[i];
                    Console.WriteLine($"{i + 1}. {specificHouse}");
                }
            }

            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.DuckHouses[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);
        }
コード例 #8
0
 public void AddDuckHouse(DuckHouse duckHouse)
 {
     DuckHouses.Add(duckHouse);
 }
コード例 #9
0
 public void AddDuckHouse(DuckHouse house)
 {
     DuckHouses.Add(house);
     Console.WriteLine("You have added a Duck house!");
 }
コード例 #10
0
 public void AddDuckHouse(DuckHouse house)
 {
     AvailableDuckHouses.Add(house);
     DuckHouses.Add(house);
 }
コード例 #11
0
 public void AddDuckHouse(DuckHouse duckHouse)
 {
     DuckHouseList.Add(duckHouse);
     FacilityList.Add(duckHouse);
 }
コード例 #12
0
 public void AddDuckHouse(DuckHouse field) => DuckHouse.Add(field);
コード例 #13
0
 public void AddDuckHouse(DuckHouse duckHouse)
 {
     DuckHouse.Add(duckHouse);
     Console.WriteLine("You have added a Duck House!");
     Thread.Sleep(1000);
 }
コード例 #14
0
 public void AddDuckHouse(DuckHouse house)
 {
     DuckHouses.Add(house);
     Console.WriteLine("A new duck house has been created.");
     Thread.Sleep(2000);
 }
コード例 #15
0
 public void AddDuckHouse(DuckHouse field)
 {
     DuckHouses.Add(field);
 }
コード例 #16
0
 public void AddDuckHouse(DuckHouse house)
 {
     DuckHouses.Add(house);
     Console.WriteLine($"New Duck House has been created!");
     Console.ReadLine();
 }
コード例 #17
0
 public void AddDuckHouse(DuckHouse field)
 {
     DuckHouses.Add(field);
     // Confirmation
     System.Console.WriteLine($"{field} has been added");
 }
コード例 #18
0
ファイル: Farm.cs プロジェクト: jisie/old-macdonald
 public void AddDuckHouse(DuckHouse house)
 {
     DuckHouses.Add(house);
     Console.WriteLine("Duck House created successfully!");
     Console.WriteLine(DuckHouses[DuckHouses.Count - 1]);
 }
コード例 #19
0
 public void AddDuckHouse(DuckHouse DH)
 {
     Console.WriteLine("Adding Duck House...");
     DuckHouses.Add(DH);
 }
コード例 #20
0
 public void AddDuckHouse(DuckHouse canopy)
 {
     DuckHouses.Add(canopy);
 }
コード例 #21
0
 public void AddDuckHouse(DuckHouse duckHouse)
 {
     DuckHouses.Add(duckHouse);
     Console.WriteLine("Your duck house has been purchased.");
 }
コード例 #22
0
 public void AddDuckHouse(DuckHouse house)
 {
     DuckHouses.Add(house);
 }
コード例 #23
0
 public void AddDuckHouse(DuckHouse pond)
 {
     DuckHomes.Add(pond);
 }