Advertisement
markovood

Untitled

Mar 25th, 2020
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.27 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PizzaCalories
  4. {
  5.     public class Dough : Ingredient
  6.     {
  7.         private string flourType;
  8.         private string bakingTechnique;
  9.         private double weight;
  10.  
  11.         public Dough(string flourType, string bakingTechnique, double weight)
  12.         {
  13.             this.FlourType = flourType;
  14.             this.BakingTechnique = bakingTechnique;
  15.             this.WeightGR = weight;
  16.  
  17.             // setting 'modifier' field
  18.             switch (this.flourType.ToLower())
  19.             {
  20.                 case "white":
  21.                     this.Modifier = 1.5;
  22.                     break;
  23.                 case "wholegrain":
  24.                     this.Modifier = 1.0;
  25.                     break;
  26.             }
  27.  
  28.             // increasing 'modifier' field
  29.             switch (this.bakingTechnique.ToLower())
  30.             {
  31.                 case "crispy":
  32.                     this.Modifier *= 0.9;
  33.                     break;
  34.                 case "chewy":
  35.                     this.Modifier *= 1.1;
  36.                     break;
  37.                 case "homemade":
  38.                     this.Modifier *= 1.0;
  39.                     break;
  40.             }
  41.         }
  42.  
  43.         private string FlourType
  44.         {
  45.             set
  46.             {
  47.                 if (value.ToLower() != "white" && value.ToLower() != "wholegrain")
  48.                 {
  49.                     throw new ArgumentException("Invalid type of dough.");
  50.                 }
  51.  
  52.                 this.flourType = value;
  53.             }
  54.         }
  55.  
  56.         private string BakingTechnique
  57.         {
  58.             set
  59.             {
  60.                 if (value.ToLower() != "crispy" && value.ToLower() != "chewy" && value.ToLower() != "homemade")
  61.                 {
  62.                     throw new ArgumentException("Invalid type of dough.");
  63.                 }
  64.  
  65.                 this.bakingTechnique = value;
  66.             }
  67.         }
  68.  
  69.         public override double WeightGR
  70.         {
  71.             get => this.weight;
  72.             protected set
  73.             {
  74.                 if (value < 1 || value > 200)
  75.                 {
  76.                     throw new ArgumentException("Dough weight should be in the range [1..200].");
  77.                 }
  78.  
  79.                 this.weight = value;
  80.             }
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement