/// <summary> /// You should definitely ask for more than fifty cents. /// </summary> /// <param name="sweet"></param> /// <param name="quantity"></param> internal void Sell(Sweet sweet, int quantity) { // We can sell candie or lollipop with a given number as amount // If we sell sweets the income will be increased by the price of the sweets and we delete it from the inventory if (inventoryOfSweets.ContainsKey(sweet.GetType())) { if (inventoryOfSweets[sweet.GetType()] >= quantity) { inventoryOfSweets[sweet.GetType()] -= quantity; money += prices[sweet.GetType()] * quantity; Console.WriteLine($"{quantity} pcs of {sweet.GetType().Name} sold for {prices[sweet.GetType()] * quantity}"); } } }
/// <summary> /// Sweeet dreams are made of these ... /// </summary> /// <param name="sweet"></param> internal void CreateSweets(Sweet sweet) { // If we create a candie or lollipop the CandyShop's sugar amount gets reduced by the amount needed to create the sweets if (sugarInventory > sweet.SugarRequired) { if (!inventoryOfSweets.ContainsKey(sweet.GetType())) { inventoryOfSweets[sweet.GetType()] = 0; } inventoryOfSweets[sweet.GetType()]++; sugarInventory -= sweet.SugarRequired; Console.WriteLine($"One pcs of {sweet.GetType().Name} created"); } else { Console.WriteLine($"No {sweet.GetType().Name} created"); } }
public void CreateSweets(Sweet sweet) { if (SugarStock > sweet.Sugar) { SweetInventory.Add(sweet); SugarStock -= sweet.Sugar; } else { Console.WriteLine($"Not enough sugar to create {sweet.GetType().Name}"); } }