Exemplo n.º 1
0
        public Card Pop(PilePosition position)
        {
            if (IsEmpty)
            {
                throw new InvalidOperationException("This pile is empty");
            }

            return(position.Pop(this));
        }
Exemplo n.º 2
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.º 3
0
        public List <Card> Pop(PilePosition position, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            if (IsEmpty)
            {
                throw new InvalidOperationException("This pile is empty");
            }

            return(position.Pop(this, count));
        }
Exemplo n.º 4
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);
        }