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); }
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); }
public void RemoveCoffeePack(CoffeePack pack) { _packs.Remove(pack); }
public void AddCoffeePack(CoffeePack pack) { _packs.Add(pack); }
protected bool Equals(CoffeePack other) { return(Weight == other.Weight && string.Equals(CoffeeKindName, other.CoffeeKindName)); }
public Builder(CoffeePack pack) { _pack = pack; }