Browse Source

docs(card_deck): correct grammar

pull/1097/head
davhojt 2 years ago committed by Dav Hojt
parent
commit
e374ccaf8b
  1. 34
      subjects/card_deck/README.md

34
subjects/card_deck/README.md

@ -2,31 +2,22 @@
### Instructions ### Instructions
A standard deck of cards has 52 cards: 4 suits and 13 cards per suit. A standard deck of cards has 52 cards: 4 suits with 13 cards per suit.
Represent the cards from a deck: Represent the cards from a deck:
- Start by creating the `Suit` enum - Create an `enum` to represent the `Suit`.
- implement the associated **function** `random` which returns a random `Suit` (`Heart`, `Diamond`, `Spade` or `Club`) - Implement the associated **function** `random`, which returns a random `Suit` (`Heart`, `Diamond`, `Spade` or `Club`).
- Then create the `Rank` enum that can have the value - Create a `Rank` enum. For ace and face cards, it can be one of `Ace`, `King`, `Queen` or `Jack`. For for the values from 2 to 10, it can have a `Number` value associated to a `u8`.
`Ace`, `King`, `Queen`, `Jack`, and `Number` associated to an `u8` - Create an associated **function** to `Rank` called `Random` that returns a random `Rank`.
value to represent the ranks 2 through 10 - Create a structure name `Card` which has the fields `suit` and `rank`.
- After create an associated **function** to `Rank` called `Random` that
returns a random `Rank`
- Finally create a structure name `Card` which has the fields `suit`
and `rank`
Define: Define:
- The associated **function** `translate` for `Rank` and `Suit`: - The associated **function** `translate` for `Rank` and `Suit`:
- For `Suit`, `translate` makes the translation between an integer value (u8) and the suit of a card (1 -> Heart, 2 -> Diamonds, 3 -> Spade, 4 -> Club) - For `Suit`, `translate` converts an integer value (`u8`) to a suit (1 -> Heart, 2 -> Diamonds, 3 -> Spade, 4 -> Club).
- For `Rank`, `translate` makes the translation between an integer value (u8) and the rank ( 1 -> Ace, 2 -> 2, .., 10 -> 10, 11 -> Jack, 12 -> Queen, 13 -> King) - For `Rank`, `translate` converts an integer value (`u8`) to a rank ( 1 -> Ace, 2 -> 2, .., 10 -> 10, 11 -> Jack, 12 -> Queen, 13 -> King).
- The associated **function** `random` for `Rank` and `Suit` which returns a random `Rank` and `Suit` respectively - The associated **function** `random` for `Rank` and `Suit` returns a random `Rank` and `Suit` respectively.
- Finally define the **function** `winner_card` which returns `true` if the card passed as an argument is an Ace of spades - Finally define the **function** `winner_card` which returns `true` if the card passed as an argument is an ace of spades.
### Notions
- [Crate rand](https://docs.rs/rand/0.3.14/rand/)
- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html)
### Dependencies ### Dependencies
@ -93,3 +84,8 @@ $ cargo run
Your card is Card { suit: Club, rank: Ace } Your card is Card { suit: Club, rank: Ace }
$ $
``` ```
### Notions
- [Crate rand](https://docs.rs/rand/0.3.14/rand/)
- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html)

Loading…
Cancel
Save