コード例 #1
0
        private static Topping CreateTopping(string command)
        {
            string[] toppingInfo = command
                                   .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                   .ToArray();

            string toppingName   = toppingInfo[1];
            int    toppingWeight = int.Parse(toppingInfo[2]);

            Topping topping = new Topping(toppingName, toppingWeight);

            return(topping);
        }
コード例 #2
0
        private void AddToppings(Pizza pizza)
        {
            string command = Console.ReadLine();

            while (command != "END")
            {
                Topping topping = CreateTopping(command);

                pizza.AddTopping(topping);

                command = Console.ReadLine();
            }
        }