Guest User

Pizza

a guest
Nov 1st, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Pizza_Calories
  8. {
  9.     class Pizza
  10.     {
  11.         private string name;
  12.         public List<Dough> doughs;
  13.         public List<Toppings> toppings;
  14.         private decimal calorieCount;
  15.         public string Name
  16.         {
  17.             get
  18.             {
  19.                 return this.name;
  20.             }
  21.  
  22.             set
  23.             {
  24.                 string formattedName = value.Trim();
  25.                 if (formattedName != "" && formattedName.Length >= 1 && formattedName.Length <= 10)
  26.                     this.name = value;
  27.                 else
  28.                     throw new Exception("Pizza name should be between 1 and 15 symbols.");
  29.             }
  30.         }
  31.         public Pizza(string name)
  32.         {
  33.             this.Name = name;
  34.             this.doughs = new List<Dough>();
  35.             this.toppings = new List<Toppings>();
  36.         }
  37.         public void AddCalories(decimal caloriesToAdd)
  38.         {
  39.             this.calorieCount = this.calorieCount + caloriesToAdd;
  40.         }
  41.         public decimal GetTotalCalories()
  42.         {
  43.             return this.calorieCount;
  44.         }
  45.     }
  46. }
Add Comment
Please, Sign In to add comment