rust-exercises icon indicating copy to clipboard operation
rust-exercises copied to clipboard

Card Deck based exercises

Open jonathanpallant opened this issue 2 years ago • 1 comments

A deck of cards is an interesting way to show ownership, because a deck has 52 cards and cards cannot be cloned or copied (unless you are cheating). The suits and face values also lend themselves to enumerations.

enum Suit {
    Hearts,
    Diamonds,
    Clubs,
    Spades
}

enum FaceValue {
    Ace,
    King,
    Queen,
    Jack,
    Ten,
    Nine,
    Eight,
    Seven,
    Six,
    Five,
    Four,
    Three,
    Two
}

There's also an interesting aside about manually implementing Ord but handling whether Aces are High or Low.

jonathanpallant avatar May 15 '23 08:05 jonathanpallant

This is an awesome idea. But we'll have to schedule this for the next round

Mirabellensaft avatar May 15 '23 15:05 Mirabellensaft