Advertisement
svetlyoek

Untitled

Jul 8th, 2019
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. namespace PizzaCalories
  2. {
  3. using System;
  4. public class Dough
  5. {
  6. private const double MIN_WEIGHT = 1;
  7. private const double MAX_WEIGHT = 200;
  8.  
  9. private const double white = 1.5;
  10. private const double wholegrain = 1.0;
  11. private const double crispy = 0.9;
  12. private const double chewy = 1.1;
  13. private const double homemade = 1.0;
  14.  
  15. private string flourType;
  16. private string bakingTechnique;
  17. private double weight;
  18.  
  19. public Dough(string flourType, string bakingTechnique, double weight)
  20. {
  21. this.FlourType = flourType;
  22. this.BakingTechnique = bakingTechnique;
  23. this.Weight = weight;
  24. }
  25.  
  26. public string FlourType
  27. {
  28. get
  29. {
  30. return this.flourType;
  31. }
  32. private set
  33. {
  34. if (value.ToLower() != "white" && value.ToLower() != "wholegrain")
  35. {
  36. throw new InvalidOperationException(ExceptionMessages.Exception.invalidDoughTypeException);
  37. }
  38.  
  39. this.flourType = value;
  40. }
  41. }
  42.  
  43. public string BakingTechnique
  44. {
  45. get
  46. {
  47. return this.bakingTechnique;
  48. }
  49. private set
  50. {
  51. if (value.ToLower() != "crispy" && value.ToLower() != "chewy" && value.ToLower() != "homemade")
  52. {
  53. throw new InvalidOperationException(ExceptionMessages.Exception.invalidDoughTypeException);
  54. }
  55.  
  56. this.bakingTechnique = value;
  57. }
  58. }
  59.  
  60. public double Weight
  61. {
  62. get
  63. {
  64. return this.weight;
  65. }
  66. private set
  67. {
  68. if (value < MIN_WEIGHT || value > MAX_WEIGHT)
  69. {
  70. throw new ArgumentException(ExceptionMessages.Exception.invalidDoughWeightException);
  71. }
  72.  
  73. this.weight = value;
  74. }
  75. }
  76.  
  77. public double CalculateCalories()
  78. {
  79. double calories = 0.0;
  80.  
  81. if (this.FlourType.ToLower() == "white" && this.BakingTechnique.ToLower() == "crispy")
  82. {
  83. calories = (2 * this.Weight) * white * crispy;
  84. }
  85.  
  86. else if (this.FlourType.ToLower() == "white" && this.BakingTechnique.ToLower() == "chewy")
  87. {
  88. calories = (2 * this.Weight) * white * chewy;
  89. }
  90.  
  91. else if (this.FlourType.ToLower() == "white" && this.BakingTechnique.ToLower() == "homemade")
  92. {
  93. calories = (2 * this.Weight) * white * homemade;
  94. }
  95.  
  96. else if (this.FlourType.ToLower() == "wholegrain" && this.BakingTechnique.ToLower() == "crispy")
  97. {
  98. calories = (2 * this.Weight) * wholegrain * crispy;
  99. }
  100.  
  101. else if (this.FlourType.ToLower() == "wholegrain" && this.BakingTechnique.ToLower() == "chewy")
  102. {
  103. calories = (2 * this.Weight) * wholegrain * chewy;
  104. }
  105.  
  106. else if (this.FlourType.ToLower() == "wholegrain" && this.BakingTechnique.ToLower() == "homemade")
  107. {
  108. calories = (2 * this.Weight) * wholegrain * homemade;
  109. }
  110.  
  111. return calories;
  112.  
  113. }
  114. }
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement