Example #1
0
 public Wheat(WheatGrade grade, WheatHardness hardness)
     : base()
 {
     this.Grade = grade;
     this.Hardness = hardness;
     this.storeAction = new StoreWheat();
     this.costCalculator = new WheatCostCalculator(this);
 }
 private WheatHardness CreateWheatHardness(string description)
 {
     if (WheatHardnessesDict.ContainsKey(description))
         return WheatHardnessesDict[description];
     else
     {
         string[] args = description.Split(new char[] { ' ' });
         if (args.Length != 2)
             throw new ArgumentException();
         string name = args[0];
         decimal cost;
         if (decimal.TryParse(args[1], out cost))
         {
             WheatHardness wheatHardness = new WheatHardness(name, cost);
             WheatHardnessesDict.Add(description, wheatHardness);
             return wheatHardness;
         }
         else
             throw new ArgumentException();
     }
 }