Exemplo n.º 1
0
        public void Push(Card card, PilePosition position)
        {
            if (CardsInPile.Contains(card, CardByRefEqualityComparer.Instance))
            {
                throw new ArgumentException("Given card instance already in pile", nameof(card));
            }

            position.Push(this, card);
        }
Exemplo n.º 2
0
        public void Push(IReadOnlyCollection <Card> cards, PilePosition position)
        {
            if (!cards.AllUnique(x => x, CardByRefEqualityComparer.Instance))
            {
                throw new ArgumentException("Duplicate instances in given cards", nameof(cards));
            }

            if (CardsInPile.Intersect(cards, CardByRefEqualityComparer.Instance).Any())
            {
                throw new ArgumentException("One of given cards instance already in pile", nameof(cards));
            }

            position.Push(this, cards);
        }