コード例 #1
0
        public static void CollectInput(Farm farm)
        {
            List <string> options = new List <string>();


            //  TODO: Check if facilites can process resources before showing the processor.
            options.Add("Seed Harvester");
            options.Add("Meat Processor");
            options.Add("Egg Gatherer");
            options.Add("Composter");

            int choice = StandardMessages.ShowMenu(options, "Choose Equipment to use...");

            switch (choice)
            {
            case 1:
                HarvestSeeds.CollectInput(farm);
                break;

            case 2:
                ProcessMeat.CollectInput(farm);
                break;

            case 3:
                GatherEggs.CollectInput(farm);
                break;

            case 4:
                Compost.CollectInput(farm);
                break;

            default:
                break;
            }
        }
コード例 #2
0
        public static void CollectInput(Farm farm)
        {
            bool doOver;

            do
            {
                Console.WriteLine("1. Seed Harvester");
                Console.WriteLine("2. Meat Processor");
                Console.WriteLine("3. Egg Gatherer");
                Console.WriteLine("4. Composter");
                Console.WriteLine();
                Console.WriteLine("Choose equipment to use");
                Console.Write("> ");
                string choice = Console.ReadLine();
                doOver = false;
                int numChoice = 0;
                try
                {
                    numChoice = Int32.Parse(choice);
                }
                catch (Exception)
                {
                    numChoice = 0;
                }
                switch (numChoice)
                {
                case 1:
                    HarvestSeeds.CollectInput(farm);
                    break;

                case 2:
                    ProcessMeat.CollectInput(farm);
                    break;

                case 3:
                    GatherEggs.CollectInput(farm);
                    break;

                case 4:
                    Compost.CollectInput(farm);
                    break;

                default:
                    Program.ShowMessage("Invalid selection.  Please choose again.");
                    doOver = true;
                    break;
                }
            } while (doOver);
        }