Advertisement
Guest User

Dough

a guest
Nov 1st, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.69 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 Dough
  10.     {
  11.         private string flourType;
  12.         private string bakingTechnique;
  13.         private decimal weight;
  14.  
  15.         public string FlourType
  16.         {
  17.             get
  18.             {
  19.                 return this.flourType;
  20.             }
  21.  
  22.             set
  23.             {
  24.                 if (value.ToLower() == "white" || value.ToLower() == "wholegrain")
  25.                     flourType = value.ToLower();
  26.                 else
  27.                     throw new Exception("Invalid type of dough.");
  28.             }
  29.         }
  30.  
  31.         public string BakingTechnique
  32.         {
  33.             get
  34.             {
  35.                 return this.bakingTechnique;
  36.             }
  37.  
  38.             set
  39.             {
  40.                 if(value.ToLower()=="crispy"||value.ToLower()=="chewy"||value.ToLower()=="homemade")
  41.                     bakingTechnique = value.ToLower();
  42.                 else
  43.                     throw new Exception("Invalid type of dough.");
  44.             }
  45.         }
  46.  
  47.         public decimal Weight
  48.         {
  49.             get
  50.             {
  51.                 return this.weight;
  52.             }
  53.  
  54.             set
  55.             {
  56.                 if(value>=1&&value<=200)
  57.                     weight = value;
  58.                 else
  59.                     throw new Exception("Dough weight should be in the range [1..200].");
  60.             }
  61.         }
  62.  
  63.         public decimal CaloriesCalculator()
  64.         {
  65.             decimal flourTypeMultiplier = 0;
  66.             decimal bakeTypeMultiplier = 0;
  67.             if (this.flourType.ToLower() == "white")
  68.                 flourTypeMultiplier = (decimal)1.5;
  69.             else if (this.flourType.ToLower() == "wholegrain")
  70.                 flourTypeMultiplier = (decimal)1.0;
  71.  
  72.             if (this.bakingTechnique.ToLower() == "crispy")
  73.                 bakeTypeMultiplier = (decimal)0.9;
  74.             else if (this.bakingTechnique.ToLower() == "chewy")
  75.                 bakeTypeMultiplier = (decimal)1.1;
  76.             else if(this.bakingTechnique.ToLower()=="homemade")
  77.                 bakeTypeMultiplier = (decimal)1.0;
  78.  
  79.             decimal totalCaloriesForDough;
  80.             totalCaloriesForDough = (this.Weight * 2)*flourTypeMultiplier*bakeTypeMultiplier;
  81.             return totalCaloriesForDough;            
  82.         }
  83.         public Dough(string flourType,string bakingTechnique,decimal weight)
  84.         {
  85.             this.FlourType = flourType;
  86.             this.BakingTechnique = bakingTechnique;
  87.             this.Weight = weight;
  88.         }
  89.         public Dough()
  90.         {
  91.  
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement