using System; using System.Configuration; /// /// This is a concrete, empty model for the buy state of the shop for you to implement /// public class BuyModel : ShopModel { public BuyModel(float pPriceModifier, int pItemCount, int pMoney) : base(pPriceModifier, pItemCount, pMoney) { } // Rather than modifying the whole class, we just reuse the existing stuff but don't make it create any items. // This makes it less work to make proper functionality, without having to break any potential old functionality. // Additionally, saves us work having to rip out the inventory's own ability to generate items. public BuyModel(ShopObject pShopInitials) : this(pShopInitials.PriceModifier, 0, pShopInitials.Money) { } //------------------------------------------------------------------------------------------------------------------------ // ConfirmSelectedItem() //------------------------------------------------------------------------------------------------------------------------ //Currently it just removes the selected item from the shop's inventory, rewrite this function and don't forget the unit test. public override void ConfirmSelectedItem() { OnRemove(GetSelectedItem()); // If there's a view subscribed, this will probably remove the item from it inventory.RemoveItemByIndex(selectedItemIndex); // Before removing the item from the model's actual inventory SelectItemByIndex(selectedItemIndex >= inventory.GetItemCount() ? --selectedItemIndex : selectedItemIndex); } }