예제 #1
0
파일: Pile.cs 프로젝트: sm-g/SimpleCards
        public Card Pop(PilePosition position)
        {
            if (IsEmpty)
            {
                throw new InvalidOperationException("This pile is empty");
            }

            return(position.Pop(this));
        }
예제 #2
0
파일: Pile.cs 프로젝트: sm-g/SimpleCards
        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);
        }
예제 #3
0
파일: Pile.cs 프로젝트: sm-g/SimpleCards
        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));
        }
예제 #4
0
파일: Pile.cs 프로젝트: sm-g/SimpleCards
        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);
        }