1 00:00:00,250 --> 00:00:03,010 All right on to the suparameter. 2 00:00:03,010 --> 00:00:07,480 Did you know that each of the suits is included in Unicode? 3 00:00:07,480 --> 00:00:11,480 Meaning that each suit is a character that we can type out. 4 00:00:11,480 --> 00:00:13,650 Let's start by replacing our suit and 5 00:00:13,650 --> 00:00:17,820 our print string with a dollar sign and then brackets. 6 00:00:18,920 --> 00:00:22,810 Inside the brackets, let's call a function that doesn't exist yet 7 00:00:22,810 --> 00:00:26,320 named getSuitChar and pass in the suit. 8 00:00:28,130 --> 00:00:30,777 Then let's use Alt+Enter to create the function. 9 00:00:36,210 --> 00:00:40,883 And after it's created, let's delete the brackets and 10 00:00:40,883 --> 00:00:46,150 then set this function equal to when suit and then add brackets. 11 00:00:47,510 --> 00:00:49,080 And inside our when statement, 12 00:00:49,080 --> 00:00:52,180 let's start by checking if the suit is equal to diamonds. 13 00:00:53,770 --> 00:01:00,086 And if it is, Then let's return the Unicode 14 00:01:00,086 --> 00:01:05,440 character for diamonds, which is \u2666. 15 00:01:06,680 --> 00:01:14,470 Next hit command or Ctrl+D three times to duplicate this line. 16 00:01:14,470 --> 00:01:19,094 And then let's change these extra 17 00:01:19,094 --> 00:01:24,522 diamonds to clubs, hearts and spades. 18 00:01:24,522 --> 00:01:30,763 And let's change the Unicode characters to u2663 for 19 00:01:30,763 --> 00:01:35,858 clubs, u2665 for hearts and u2660 for 20 00:01:35,858 --> 00:01:42,590 spades, these are all in the teacher's notes as well. 21 00:01:42,590 --> 00:01:47,020 Finally, since we're counting on this when statement to always return something 22 00:01:47,020 --> 00:01:48,000 let's add an else. 23 00:01:49,950 --> 00:01:52,030 And if we get anything else, 24 00:01:52,030 --> 00:01:57,500 let's return a string that says incorrect suit then let's run the app. 25 00:02:00,370 --> 00:02:02,540 And sweet, I got the ten of spades. 26 00:02:02,540 --> 00:02:03,640 My favorite. 27 00:02:03,640 --> 00:02:07,310 Last but not least, let's deal with the face up property. 28 00:02:07,310 --> 00:02:10,820 If a card is face up, we should be able to see it. 29 00:02:10,820 --> 00:02:14,820 But if it's face down, we shouldn't be able to tell what card it is. 30 00:02:14,820 --> 00:02:19,220 So really, I shouldn't be able to tell that this card is a ten of spades. 31 00:02:20,700 --> 00:02:25,191 To fix this, let's first take the face up property out of our print string. 32 00:02:29,279 --> 00:02:35,550 Then let's add a line above the return and type if faceUp. 33 00:02:37,460 --> 00:02:40,120 And then put our return statement inside the brackets. 34 00:02:41,500 --> 00:02:47,840 Next let's add an else and if it's not face up, let's return three Xs. 35 00:02:51,100 --> 00:02:56,720 Great, but before we move on, let's make this two string function a lot smaller. 36 00:02:56,720 --> 00:03:01,010 To do that, I first need to tell you about the ternary operator and column. 37 00:03:01,010 --> 00:03:03,060 Remember the Ternary Operator? 38 00:03:03,060 --> 00:03:04,330 It's these guys. 39 00:03:04,330 --> 00:03:07,860 They let us do a conditional statement on only one line. 40 00:03:07,860 --> 00:03:11,810 See, the thing is, Kotlin doesn't have a Ternary Operator. 41 00:03:11,810 --> 00:03:16,100 Instead, with Kotlin, an if statement returns a value. 42 00:03:16,100 --> 00:03:20,460 So instead of using some weird syntax, we can just use if and 43 00:03:20,460 --> 00:03:22,280 else like we're used to. 44 00:03:22,280 --> 00:03:24,380 So to get this down to one line, 45 00:03:24,380 --> 00:03:30,190 let's first delete the outside brackets and then add an equal sign. 46 00:03:30,190 --> 00:03:36,049 Then, since if statements already return values, let's delete the return keywords. 47 00:03:41,328 --> 00:03:45,418 And finally, let's get rid of the brackets and put everything on one line. 48 00:03:59,360 --> 00:04:03,540 Awesome, our two string function is ready for action. 49 00:04:03,540 --> 00:04:07,777 Now let's give it some exercise by printing out the entire game board instead 50 00:04:07,777 --> 00:04:09,550 of just the top card in our deck.