示例#1
0
        private STATES SelectPersons()
        {
            if (currentOrder.Typs.Count > 0)
            {
                Console.WriteLine("Your current Types:");
                foreach (var typ in currentOrder.Typs)
                {
                    Console.WriteLine(typ.ToString());
                }
            }
            Console.WriteLine("Select your Type:");
            foreach (Typ typ in (Typ[])Enum.GetValues(typeof(Typ)))
            {
                //TODO: maybe show prices?
                Console.WriteLine($"{(int)typ}. {typ.ToString()}");
            }
            var input = Console.ReadLine();
            Typ intput;

            //Check
            if (input == "c")
            {
                return(STATES.MENU);
            }
            if (!Typ.TryParse(input, out intput) || !Enum.IsDefined(typeof(Typ), intput))
            {
                return(STATES.SELECT_PERSONS);
            }

            //Add to current order
            currentOrder.Typs.Add(intput);
            Console.WriteLine("Do you want to add another person? (y/n)");
            input = Console.ReadLine();
            switch (input)
            {
            case "y":
                return(STATES.SELECT_PERSONS);

            case "c":
                return(STATES.MENU);

            default:
            case "n":
                return(STATES.SELECT_PERSONS + 1);
            }
        }