Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace PizzaCalories
- {
- public class Dough
- {
- private const double MinWeight = 1;
- private const double MaxWeight = 200;
- private const double white = 1.5;
- private const double wholegrain = 1.0;
- private const double crispy = 0.9;
- private const double chewy = 1.1;
- private const double homemade = 1.0;
- private string flourType;
- private string bakingTechnique;
- private double weight;
- public Dough(string flourType, string bakingTechnique, double weight)
- {
- this.FlourType = flourType;
- this.BakingTechnique = bakingTechnique;
- this.Weight = weight;
- }
- public string FlourType
- {
- get => this.flourType;
- set
- {
- if (value.ToLower() != "white" && value.ToLower() != "wholegrain")
- {
- throw new ArgumentException(Exceptions.InvalidDoughTypeException);
- }
- this.flourType = value;
- }
- }
- public string BakingTechnique
- {
- get => this.bakingTechnique;
- set
- {
- if (value.ToLower() != "crispy" && value.ToLower() != "chewy" && value.ToLower() != "homemade")
- {
- throw new ArgumentException(Exceptions.InvalidDoughTypeException);
- }
- this.bakingTechnique = value;
- }
- }
- public double Weight
- {
- get => this.weight;
- set
- {
- if (value < MinWeight || value > MaxWeight)
- {
- throw new ArgumentException(Exceptions.InvalidDoughWeightException);
- }
- this.weight = value;
- }
- }
- public double CalculateCalories()
- {
- double calories = 0.0;
- switch (FlourType.ToLower())
- {
- case "white":
- switch (bakingTechnique.ToLower())
- {
- case "crispy": calories = 2 * this.Weight * white * crispy; break;
- case "chewy": calories = 2 * this.Weight * white * chewy; break;
- case "homemade": calories = 2 * this.Weight * white * homemade; break;
- default:
- break;
- }; break;
- case "wholegrain":
- switch (bakingTechnique.ToLower())
- {
- case "crispy": calories = 2 * this.Weight * wholegrain * crispy; break;
- case "chewy": calories = 2 * this.Weight * wholegrain * chewy; break;
- case "homemade": calories = 2 * this.Weight * wholegrain * homemade; break;
- default:
- break;
- }; break;
- default:
- break;
- }
- return calories;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement