Beispiel #1
0
        public bool BuyItem(Item item, Shop shop)
        {
            if (item.Value > Money)
            {
                Console.WriteLine("You don't have enough money.");
                return false;
            }

            if (shop.SellItem(item))
            {
                Money -= item.Value;
                Bag.AddItem(item);
            }
            return true;
        }
Beispiel #2
0
        public bool SellItem(Item item, Shop shop)
        {
            if (!Bag.HasItem(item))
            {
                Console.WriteLine("{0} doesn't have {1} in his bag.", Name, item.Name);
                return false;
            }

            int moneyfromSale = shop.BuyUsedfromPlayer(item);

            if (moneyfromSale != 0)
            {
                Bag.RemoveItem();
                Money += moneyfromSale;
            }
            Console.WriteLine("{0} sells his {1} to get {2} dollars", Name, item.Name, moneyfromSale);
            return true;
        }