예제 #1
0
    public int CompareTo(Card other)
    {
        if (ReferenceEquals(this, other))
        {
            return(0);
        }
        if (ReferenceEquals(null, other))
        {
            return(1);
        }
        var rankComparison = rank.CompareTo(other.rank);

        if (rankComparison != 0)
        {
            return(rankComparison);
        }
        var suitComparison = suit.CompareTo(other.suit);

        if (suitComparison != 0)
        {
            return(suitComparison);
        }
        var powerComparison = power.CompareTo(other.power);

        if (powerComparison != 0)
        {
            return(powerComparison);
        }
        var rankComparison1 = Rank.CompareTo(other.Rank);

        if (rankComparison1 != 0)
        {
            return(rankComparison1);
        }
        return(Suit.CompareTo(other.Suit));
    }