Playing Card in Swift I'm trying to properly write a card class in swift. I've been taking classes in software engineering and I need help in understanding how to take a more object-oriented approach to my class. I have seen a Class for suit and rank and I'm wondering would that approach would be better? I have also seen the suit as enums and wonder if that approach would be better. 

Any help will be appreciated.

Thank you

class Card

private var rank: Int
private var suit: Int

init(n: Int) {
    self.rank = -1;
    self.suit = -1;
    if(n &gt;= 0 &amp;&amp; n &lt;= 51) {
        self.rank = n % 13;
        self.suit = n / 13;
    }
}

func getRank() -&gt; Int {
    return self.rank;
}

func getSuit() -&gt; Int {
    return self.suit;
}

func compareRank(otherCard: Card) -&gt; Bool {
    return self.rank == otherCard.getRank();
}

func compareSuit(otherCard: Card) -&gt; Bool {
    return self.suit == otherCard.getSuit();
}
In addition to what @Carpsen90 said:

No get... accessor methods

Unlike some other programming languages, you don't define accessor methods for the properties, these are implicitly created by the compiler. If suit and rank are constant properties (initialized once and never mutated) then it is simply

struct Card {
    let rank: Int
    let suit: Int

    // ...
}


For properties which are publicly read-only, but internally read-write, it is

 struct Card {
    private(set) var rank: Int
    private(set) var suit: Int

    // ...
}


That makes the compareRank/Suit methods obsolete, because you can directly  test

if card1.rank == card2.rank { ... }


etc.