Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- class Pizza
- {
- private string name;
- private Dough dough;
- private List<Topping> toppings;
- public Pizza(string name, Dough dough, List<Topping> toppings)
- {
- Name = name;
- Dough = dough;
- Toppings = toppings;
- }
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- if (string.IsNullOrEmpty(value) || value.Length > 15)
- {
- throw new ArgumentException("Pizza name should be between 1 and 15 symbols.");
- }
- name = value;
- }
- }
- public List<Topping> Toppings
- {
- get
- {
- return toppings;
- }
- set
- {
- if (value.Count > 10)
- {
- throw new ArgumentException("Number of toppings should be in range [0..10].");
- }
- toppings = value; // comment this
- }
- }
- public Dough Dough
- {
- get
- {
- return dough;
- }
- set
- {
- dough = value;
- }
- }
- public double CalculateTotalCalories()
- {
- return dough.CalculateCalories() + toppings.Sum(t => t.CalculateCalorys());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement