Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication15
- {
- public class Dough
- {
- private string flour;
- private string technique;
- private double weight;
- private double calories;
- public string Flour
- {
- get { return flour; }
- set { flour = value; }
- }
- public string Technique
- {
- get { return technique; }
- set { technique = value; }
- }
- public double Weight
- {
- get { return weight; }
- set
- {
- if (value < 1 || value > 200)
- {
- throw new ArgumentException("Dough weight should be in the range [1..200].");
- }
- weight = value;
- }
- }
- public double Calories
- {
- get { return calories; }
- private set { calories = value; }
- }
- public Dough(string flour, string technique, double weight)
- {
- this.flour = flour;
- this.technique = technique;
- this.weight = weight;
- calories = CalculateCalories();
- }
- public double GetFlourValue()
- {
- switch (flour)
- {
- case "White":
- return 1.5;
- case "Wholegrain":
- return 1.5;
- default:
- throw new ArgumentException("Invalid type of dough.");
- }
- }
- public double GetTechniqueValue()
- {
- switch (technique)
- {
- case "Crispy":
- return 0.9;
- case "Chewy":
- return 1.1;
- case "Homemade":
- return 1.0;
- default:
- throw new ArgumentException("Invalid type of dough.");
- }
- }
- private double CalculateCalories()
- {
- return (2.0 * weight) * GetFlourValue() * GetTechniqueValue();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement