예제 #1
0
        internal void tradeCandy(string tradedCandy, string newCandy, CandyStorage ownerName)
        {
            var ownerCandy  = _myCandy.Find(candy => candy.Name == tradedCandy);
            var traderCandy = ownerName._myCandy.Find(candy => candy.Name == newCandy);

            //Adds new candies to each owners' lists
            ownerName.SaveNewCandy(ownerCandy);
            _myCandy.Add(traderCandy);

            //Removes traded candies from owners' lists
            ownerName.RemoveCandyFromInventory(traderCandy);
            _myCandy.Remove(ownerCandy);
        }