This course has been updated! We now recommend you take the TypeScript Fundamentals, v3 course.
Transcript from the "Challenge 3: Card Dealing" Lesson
>> Mike North: Let's jump in to the third exercise of the day. So our task here is to build a card dealer. We gonna build a card dealing program. We're gonna using an enum to define suit, and likely an enum to define the card number. Where ace is zero, got ace, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, but ace is the lowest.
[00:00:31] So cards should be represented as a tuple of size two with the suit first and the card number second. For example 0, 6 is seven of clubs. The order of the suits, just so you see there, is alphabetical. So don't make that mistake or the test will fail.
[00:00:53] Alphabetical, which is, that's not the right order is it? Let me fix that. Sorry y'all. There we go. So that's how I was getting five of a kind earlier. So each dealer should have its own deck of cards, by that you should look at the dealer class, it should have member data, right?
[00:01:12] It should have an instance property where the cards are stored. I've given you a shuffle method that you can use to shuffle an array in place. So you can shuffle your cards. And your job is to pass all currently failing tests. Just in case the tests are not enough to give you an idea of what I'm looking for here, this is the kind of stuff I'm looking for this dealer class to do.
[00:01:38] You should be able to deal a hand of five cards. You should be able to tell me how many cards are left in your deck. So when you deal cards, you should lose cards out of your deck, right? So I should be able to ask for five cards.
[00:01:52] You go down from 52 to 47. You should be able to tell me what card I have. So I should be able to pass you a tuple, and you can send me back a string saying seven of spades or three of hearts, something like that. And then you should use this shuffle function which is already in the starting point for the exercise to, after you create your deck shuffle it and then you should be dealing out cards as requested.
[00:02:19] Does that make sense to everyone? Npm test dealer, that's how you're gonna run this test. And make sure that you have no complaints from the TypeScript compiler and no failing tests, and that's how you'll know you're at the end of the exercise.