示例#1
0
        public bool IsDeckSorted()
        {
            ICard smallerCard = DealTopCard();

            do
            {
                try
                {
                    ICard nextCard = DealTopCard();
                    if (smallerCard.IsGreaterSuit(nextCard))
                    {
                        return(false);
                    }
                    else
                    {
                        if (smallerCard.EqualsSuit(nextCard) && smallerCard.IsGreaterRank(nextCard))
                        {
                            return(false);
                        }
                    }
                    smallerCard = nextCard;
                } catch (DeckException)
                {
                    // if we made it this far, then it is sorted
                    return(true);
                }
            } while (smallerCard != null);
            return(true);
        }