public static void CollectInput(Farm farm, Sunflower sunflower)
        {
            Console.WriteLine("1. Natural Field");
            Console.WriteLine("2. Plowing Field");
            Console.WriteLine("");
            Console.WriteLine("Where would you like to Place your Sunflower?");

            Console.WriteLine("> ");

            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseNaturalField.CollectInput(farm, sunflower);
                break;

            case 2:
                ChoosePlowingField.CollectInput(farm, sunflower);
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm, Sunflower Sunflower)
        {
            Console.Clear();

            Console.WriteLine("1. Natural Field");
            Console.WriteLine("2. Plowed Field");

            Console.WriteLine();
            // README code
            Console.WriteLine("Choose which type of field to plant the Sunflower seed in.");
            // Old code
            // Console.WriteLine ("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseNaturalField.CollectInput(farm, new Sunflower());
                break;

            case 2:
                ChoosePlowedField.CollectInput(farm, new Sunflower());
                break;
            }
        }
Пример #3
0
        public static void CollectInput(Farm farm, Sunflower plant)
        {
            Console.Clear();

            int menuNumber = 1;

            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                Console.WriteLine($"{menuNumber}. Natural Field");
                menuNumber++;
            }

            for (int i = 0; i < farm.PlowedFields.Count; i++)
            {
                Console.WriteLine($"{menuNumber}. Plowed Field");
                menuNumber++;
            }

            Console.WriteLine();
            Console.WriteLine($"Place the {plant.Type} where?");

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

            // farm.GrazingFields[choice].AddResource(animal);  TODO: Have this bug for boilerplate
            farm.NaturalFields[choice - 1].AddResource(plant);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             *      https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/introduction-to-generics
             */
            // farm.PurchaseResource<IGrazing>(animal, choice-1);
        }
Пример #4
0
 public void AddPlantResource(Sunflower sunflower)
 {
     if (_naturalFieldFlowerList.Count < _capacity)
     {
         _naturalFieldFlowerList.Add(sunflower);
         ResourceList.Add(sunflower);
     }
 }
 public void AddPlantResource(Sunflower plant)
 {
     if (_plowedFieldFlowerList.Count < _capacity)
     {
         _plowedFieldFlowerList.Add(plant);
         ResourceList.Add(plant);
     }
 }
Пример #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Problem logs: ");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * Problem:
             * Class Flower doesn't work without Electricity and Lamp Classes.
             * And if I want to change Lamp to another class (ex. Sun),
             * that mean I need to modify Flower class
             * (which doesn't recommended by Open-Closed Principle)
             *
             * Also if I want to test Flower class with simulation of light (mock lamp)
             * I can't do this.
             */
            var myFlower = new Flower();

            myFlower.StartPhotosynthesis();

            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Fabric method logs:");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * We pulled the water object out of the Rose class
             * That mean if I want to use mockWater, I can use WaterFactory for that
             */
            var myRoses = new Rose();

            myRoses.StartGrowing();

            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Add abstraction logs:");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * I implemented Dependency Injection Principle:
             * High-level Sunflower not depend on Low-level Sun
             * Both depend on Interface
             */

            var myShinySunflower = new Sunflower();

            myShinySunflower.Shining();

            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Use Injector class:");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * Injector class decline coupling between Poppy (Some Business Logic) and Wind (Data Source)
             */

            var myLovelyPoppy = new PoppyService();

            myLovelyPoppy.Disperse();
        }
Пример #7
0
 public static void CollectInput(Farm farm, Sunflower sunflower)
 {
     Console.Clear();
     Console.WriteLine();
     Console.WriteLine("  1");
     Console.WriteLine("  2");
     Console.WriteLine("  3");
     Console.WriteLine("  4");
     Console.WriteLine("  5");
     Console.WriteLine("  6");
     Console.WriteLine("  7");
     Console.WriteLine();
     Console.WriteLine($"How many rows of Sunflowers would you like to plant?");
     Console.Write("> ");
     string choice = Console.ReadLine();
 }
 public void AddResource(Sunflower sunflower)
 {
     if (_plants.Count < Capacity)
     {
         for (int i = 0; i < 6; i++)
         {
             _plants.Add(sunflower);
         }
         string shortId = this._id.ToString().Substring(this._id.ToString().Length - 6);
         Console.WriteLine($"6 sunflowers add to natural field {shortId}.");
         Thread.Sleep(2000);
     }
     else
     {
         Console.WriteLine("This natural field is at capacity.");
         Thread.Sleep(2000);
     }
 }
 internal static void CollectInput(Farm farm, Sunflower sunflower)
 {
     throw new NotImplementedException();
 }
 public void ReadSunflowers()
 {
     StreamReader Reader;    // reads the raw data
     string Line;           // line in raw data
     Sunflower Sunflower;    // Populated sunflower data adding
     int CellCount;          // Count of cell
     CellContents CellContent;  // Contents of cell working with
     int IntResult;          // Result of tryparse integer
     decimal DecResult;      // Result of tryparse decimal
     DateTime DateResult;    // Result of tryparse date
     //
     Reader=new StreamReader("C:\\Turing Sunflower raw data.csv");
     // Ignore first line
     Reader.ReadLine();
     //
     // Now read raw sunflower data
     while (!Reader.EndOfStream)
     {
         Line=Reader.ReadLine();
         Sunflower = new Sunflower();
         CellCount=0;
         foreach (string Cell in Line.Split(','))
         {
             CellContent=(CellContents)CellCount;
             switch (CellContent)
             {
                 case CellContents.BractCount:
                     int.TryParse(Cell,out IntResult);
                     Sunflower.BractCount = IntResult;
                     break;
                 case CellContents.Country:
                     Sunflower.Country = Cell;
                     break;
                 case CellContents.FlowerName:
                     Sunflower.FlowerName = Cell;
                     break;
                 case CellContents.GrowContainer:
                     Sunflower.Grow.Container = Cell;
                     break;
                 case CellContents.GrowLocation:
                     Sunflower.Grow.Location = Cell;
                     break;
                 case CellContents.HeadDiamter:
                     decimal.TryParse(Cell, out DecResult);
                     Sunflower.HeadDiameter = DecResult;
                     break;
                 case CellContents.Height:
                     decimal.TryParse(Cell, out DecResult);
                     Sunflower.Height = DecResult;
                     break;
                 case CellContents.ID:
                     int.TryParse(Cell, out IntResult);
                     Sunflower.PKey = IntResult;
                     break;
                 case CellContents.LeafDirection:
                     Sunflower.LeafDirection = Cell;
                     break;
                 case CellContents.NoOfHeads:
                     int.TryParse(Cell, out IntResult);
                     Sunflower.NoOfHeads = IntResult;
                     break;
                 case CellContents.PlantedContainer:
                     Sunflower.Planted.Container = Cell;
                     break;
                 case CellContents.PlantedDirection:
                     Sunflower.Planted.Direction = Cell;
                     break;
                 case CellContents.PlantedLocation:
                     Sunflower.Planted.Location = Cell;
                     break;
                 case CellContents.PlantSize:
                     Sunflower.PlantSize = Cell;
                     break;
                 case CellContents.Postcode:
                     Sunflower.Postcode = Cell;
                     break;
                 case CellContents.SeedName:
                     Sunflower.SeedName = Cell;
                     break;
                 case CellContents.SpiralCountA:
                     int.TryParse(Cell, out IntResult);
                     Sunflower.SpiralCountA = IntResult;
                     break;
                 case CellContents.SpiralCountB:
                     int.TryParse(Cell, out IntResult);
                     Sunflower.SpiralCountB = IntResult;
                     break;
                 case CellContents.WhenPicked:
                     DateTime.TryParse(Cell,out DateResult);
                     Sunflower.WhenPicked = DateResult;
                     break;
                 case CellContents.WhenPlanted:
                     DateTime.TryParse(Cell, out DateResult);
                     Sunflower.WhenPlanted = DateResult;
                     break;
             }
             CellCount+=1;
         }
         Add(Sunflower);
     }
 }
 public void Add(Sunflower Sunflower)
 {
     List.Add(Sunflower);
 }
        // figure out a way for natural and plowed fields to exist in the same list
        // or
        // run another for loop
        public static void CollectInput(Farm farm, Sunflower plant)
        {
            Utils.Clear();

            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                if (farm.NaturalFields[i].PlantCount() < farm.NaturalFields[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Natural Field");
                    Console.WriteLine($"\t This field has {farm.NaturalFields[i].PlantCount()} plants currently!\n");
                    var SunflowerCount = 0;
                    SunflowerCount = farm.NaturalFields[i].NaturalPlantList()
                                     .Where(plantType => plantType.Type == "Sunflower")
                                     .Count();
                    Console.WriteLine($"\t \t There are {SunflowerCount} rows of Sunflowers!");
                    var WildflowerCount = 0;
                    WildflowerCount = farm.NaturalFields[i].NaturalPlantList()
                                      .Where(plantType => plantType.Type == "Wildflower")
                                      .Count();
                    Console.WriteLine($"\t \t There are {WildflowerCount} rows of Wildflowers!");
                }
            }
            for (int i = farm.NaturalFields.Count; i < farm.PlowedFields.Count + farm.NaturalFields.Count; i++)
            {
                var plowedFieldIndex = i - farm.NaturalFields.Count;
                if (farm.PlowedFields[plowedFieldIndex].PlantCount() < farm.PlowedFields[plowedFieldIndex].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Plowed Field");
                    Console.WriteLine($"\t This field has {farm.PlowedFields[plowedFieldIndex].PlantCount()} plants currently!\n");
                    var SunflowerCount = 0;
                    SunflowerCount = farm.PlowedFields[plowedFieldIndex].PlowedPlantList()
                                     .Where(plantType => plantType.Type == "Sunflower")
                                     .Count();
                    Console.WriteLine($"\t \t There are {SunflowerCount} rows of Sunflowers!");
                    var SesameCount = 0;
                    SesameCount = farm.PlowedFields[plowedFieldIndex].PlowedPlantList()
                                  .Where(plantType => plantType.Type == "Sesame")
                                  .Count();
                    Console.WriteLine($"\t \t There are {SesameCount} rows of Sesame!");
                }
            }



            Console.WriteLine();

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

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

            if (choice <= farm.NaturalFields.Count)
            {
                farm.NaturalFields[choice - 1].AddResource(plant);
            }
            else if (choice > farm.NaturalFields.Count)
            {
                farm.PlowedFields[choice - 1 - farm.NaturalFields.Count].AddResource(plant);
            }

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IPlowing>(plant, choice);
        }