コード例 #1
0
        public static void MakePizza(string[] tokens)
        {
            var numberToppings = int.Parse(tokens[2]);
            var pizza          = new Pizza(tokens[1], numberToppings);
            var doughInfo      = Console.ReadLine().Split(' ');
            var dough          = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3]));

            pizza.Dough = dough;

            for (var i = 0; i < numberToppings; i++)
            {
                var topInfo = Console.ReadLine().Split(' ');
                var topping = new Topping(topInfo[1], double.Parse(topInfo[2]));
                pizza.AddTopping(topping);
            }

            Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories.");
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            try
            {
                string[] pizzaProps = Console.ReadLine().Split();

                string name = pizzaProps[1];

                string[] doughProps = Console.ReadLine().Split();
                string   type       = doughProps[1];
                string   tech       = doughProps[2];
                double   grams      = double.Parse(doughProps[3]);

                Dough dough = new Dough(type, tech, grams);

                Pizza pizza = new Pizza(name, dough);

                while (true)
                {
                    string command = Console.ReadLine();

                    if (command == "END")
                    {
                        break;
                    }

                    string[] input = command.Split();

                    string typeTopping  = input[1];
                    double gramsTopping = double.Parse(input[2]);

                    Topping topping = new Topping(typeTopping, gramsTopping);
                    pizza.Add(topping);
                }
                Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories.");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
        }
コード例 #3
0
 public Pizza(string name, Dough dough)
 {
     this.Name     = name;
     this.dough    = dough;
     this.toppings = new List <Topping>();
 }
コード例 #4
0
 public Pizza(string name, Dough dough, Topping topping) : this(name, dough)
 {
     this.Topping = topping;
 }
コード例 #5
0
 public Pizza(string name, Dough dough) : this(name)
 {
     this.Dough = dough;
 }