1 00:00:00,230 --> 00:00:04,750 Instead of just showing us the top card on the deck, let's print out the entire game. 2 00:00:04,750 --> 00:00:08,955 That way, if we hit any road blocks, it'll be easy to see what's wrong. 3 00:00:08,955 --> 00:00:12,290 Let's first get rid of the extra space in our Card class. 4 00:00:12,290 --> 00:00:14,795 And then back in our GameModel class, 5 00:00:14,795 --> 00:00:18,487 let's start by clearing out the debug print function. 6 00:00:21,040 --> 00:00:25,030 Within, let's take a look at how we're going to print out the game. 7 00:00:25,030 --> 00:00:29,584 After we've called the resetGame function, the game should look something like this. 8 00:00:29,584 --> 00:00:32,814 To print this, we'll start by turning it into a grid. 9 00:00:32,814 --> 00:00:35,605 Each cell in this grid will be six characters long. 10 00:00:35,605 --> 00:00:37,669 [SOUND] Three characters for the data. 11 00:00:37,669 --> 00:00:41,174 [SOUND] And three characters for the spaces between each cell. 12 00:00:41,174 --> 00:00:44,475 On the first line, we'll print the top card of the waste pile, 13 00:00:44,475 --> 00:00:48,790 then will leave two cells empty and print the top card in each foundation. 14 00:00:48,790 --> 00:00:51,900 Or if the foundation is empty, we'll print something else. 15 00:00:51,900 --> 00:00:56,921 Next, we'll add some space before our Tableau piles by printing a blank line. 16 00:00:56,921 --> 00:00:59,534 Then, we need to print our Tableau piles. 17 00:00:59,534 --> 00:01:04,427 To do this, we're first going to change our grid to allocate 13 rows to 18 00:01:04,427 --> 00:01:08,841 our Tableau piles, then we're going to loop through the rows and 19 00:01:08,841 --> 00:01:12,760 if the Tableau pile has a card index, we print it. 20 00:01:12,760 --> 00:01:15,370 Otherwise, we'll just print three spaces. 21 00:01:15,370 --> 00:01:19,240 And once that's done, we'll know exactly what our game looks like. 22 00:01:19,240 --> 00:01:20,730 So first things, first. 23 00:01:20,730 --> 00:01:22,820 Before we get around to printing again. 24 00:01:22,820 --> 00:01:24,840 Let's jump back to our card class and 25 00:01:24,840 --> 00:01:29,190 make sure that each card will be exactly three characters long. 26 00:01:29,190 --> 00:01:32,320 And I'll put this on a new line, so it's just a little bit easier to see. 27 00:01:33,790 --> 00:01:35,780 Right now, we've got the cards value. 28 00:01:37,300 --> 00:01:39,990 And then a space, and then the card suit. 29 00:01:41,340 --> 00:01:44,490 But if the cards value is a ten, 30 00:01:44,490 --> 00:01:49,140 then this is going to be four characters and our grid will look a little off. 31 00:01:49,140 --> 00:01:53,766 To fix this, lets first split these out into two separate strings and 32 00:01:53,766 --> 00:01:56,336 then add those two strings together. 33 00:01:59,518 --> 00:02:00,890 So one string for the value. 34 00:02:01,890 --> 00:02:02,890 One string for the suit. 35 00:02:05,710 --> 00:02:10,420 And then add them together, so far we've just gotten rid of the space in between. 36 00:02:10,420 --> 00:02:17,150 Next, after the first string, type .padEnd(2). 37 00:02:17,150 --> 00:02:18,550 Pad in, 38 00:02:18,550 --> 00:02:23,400 adds spaces to the end of our string until it reaches a specified length. 39 00:02:23,400 --> 00:02:25,188 In our case, 2. 40 00:02:25,188 --> 00:02:28,370 It's also an extension function on the string class. 41 00:02:28,370 --> 00:02:31,770 So now, if we've got something like the six of clubs. 42 00:02:31,770 --> 00:02:35,950 The six will get an extra space after it to make it two characters long. 43 00:02:35,950 --> 00:02:37,870 And if we've got the ten of diamonds, 44 00:02:37,870 --> 00:02:42,120 since ten is already two characters, it won't add anything. 45 00:02:42,120 --> 00:02:46,600 Meaning, now our two string function always returns a three character string. 46 00:02:47,980 --> 00:02:49,250 Perfect. 47 00:02:49,250 --> 00:02:53,240 And the next video, will get back to where we left off with our debug print function.