Beispiel #1
0
            public CoffeePack Finish()
            {
                var res = _pack;

                if (string.IsNullOrEmpty(res.CoffeeKindName))
                {
                    throw new InvalidOperationException("Coffee kind name can't be an empty string");
                }

                if (string.IsNullOrEmpty(res.TorrefactoId))
                {
                    throw new InvalidOperationException("Torrefacto ID can't be an empty string");
                }

                if (res.Weight <= 0)
                {
                    throw new InvalidOperationException("Weight must be positive");
                }

                if (res.Price <= 0)
                {
                    throw new InvalidOperationException("Price must be positive");
                }

                _pack = null;
                return(res);
            }
Beispiel #2
0
        public string GetActualTorrefactoId(CoffeePack pack)
        {
            var ix = _availablePacks.IndexOf(pack);

            if (ix == -1)
            {
                throw new ArgumentException("Unknown coffee pack: " + pack);
            }

            pack = _availablePacks[ix];
            return(pack.TorrefactoId);
        }
Beispiel #3
0
 public void RemoveCoffeePack(CoffeePack pack)
 {
     _packs.Remove(pack);
 }
Beispiel #4
0
 public void AddCoffeePack(CoffeePack pack)
 {
     _packs.Add(pack);
 }
Beispiel #5
0
 protected bool Equals(CoffeePack other)
 {
     return(Weight == other.Weight && string.Equals(CoffeeKindName, other.CoffeeKindName));
 }
Beispiel #6
0
 public Builder(CoffeePack pack)
 {
     _pack = pack;
 }