1 00:00:00,770 --> 00:00:05,960 We have learned about the fundamental data type in the previous sections of our course. 2 00:00:05,960 --> 00:00:12,260 And this data type is used in defining or initializing a variable to ensure that a variable can store 3 00:00:12,260 --> 00:00:13,530 the selected data type. 4 00:00:13,550 --> 00:00:20,030 However, there are other data types that can be used to define a variable and they are enum, which 5 00:00:20,030 --> 00:00:22,580 is enumeration and struct. 6 00:00:22,590 --> 00:00:31,610 So enumeration is a data type that has several possible values and they are defined as the constant, 7 00:00:31,610 --> 00:00:35,090 which is called the enumerators. 8 00:00:35,090 --> 00:00:37,550 So it is used to create a collection of constants. 9 00:00:37,550 --> 00:00:39,680 So let's actually make an example. 10 00:00:39,950 --> 00:00:46,580 So suppose we want to develop a card game, the card game using. 11 00:00:48,230 --> 00:00:57,890 Which actually the this card game as you know, the deck of playing cards contains 52 cards. 12 00:00:58,980 --> 00:01:02,400 52 cards and. 13 00:01:04,080 --> 00:01:06,240 Oops, let me fix this. 14 00:01:08,490 --> 00:01:11,050 So 52 cards. 15 00:01:11,050 --> 00:01:17,260 The deck of playing contains the 52 cards, which consists of four suits. 16 00:01:17,280 --> 00:01:21,330 The first is Clubs C. 17 00:01:21,930 --> 00:01:25,560 Then we have the diamonds. 18 00:01:25,590 --> 00:01:26,520 The. 19 00:01:27,330 --> 00:01:29,160 Then we have hordes. 20 00:01:30,280 --> 00:01:31,030 Age. 21 00:01:31,990 --> 00:01:42,940 And then we have the spades, which is s so, so we have 13 elements in each suite here. 22 00:01:42,970 --> 00:01:44,560 13 element. 23 00:01:44,590 --> 00:01:47,770 13 cards in each suite. 24 00:01:48,400 --> 00:01:52,300 13 and 13 here. 25 00:01:52,510 --> 00:01:59,370 So we can notate the card in the C plus plus class here as follows here. 26 00:01:59,380 --> 00:02:01,750 Firstly, we're going to create an enum here. 27 00:02:01,780 --> 00:02:04,780 This enum type is going to be card suites. 28 00:02:04,780 --> 00:02:13,120 So as we discussed earlier, we have four card suites, so Club Diamond Heart. 29 00:02:15,970 --> 00:02:17,350 And spade. 30 00:02:19,040 --> 00:02:19,670 Here. 31 00:02:19,670 --> 00:02:27,590 And we also need to create the card elements, which, as we talked about earlier, we have 13 card 32 00:02:27,590 --> 00:02:30,260 elements in each of these suits. 33 00:02:30,260 --> 00:02:45,170 So enum card elements and we here we have ace two, three, four, five, six, seven, eight, nine, 34 00:02:46,160 --> 00:02:46,970 ten. 35 00:02:48,230 --> 00:02:49,340 The jack. 36 00:02:50,170 --> 00:02:52,660 Queen and king. 37 00:02:52,840 --> 00:03:01,600 So if we apply to all the preceding the enum data types, we can create a following initial variable 38 00:03:01,600 --> 00:03:02,650 installation here. 39 00:03:02,650 --> 00:03:03,400 So card. 40 00:03:03,730 --> 00:03:06,100 So we're going to create a new card suits here. 41 00:03:06,130 --> 00:03:06,640 Oops. 42 00:03:08,530 --> 00:03:10,850 And here we're going to cart sweets. 43 00:03:10,910 --> 00:03:12,040 Sweet here. 44 00:03:12,040 --> 00:03:18,010 And it's going to be in this case, it's going to be let's actually make it spayed and we will create 45 00:03:18,010 --> 00:03:20,080 a cart element, choose the cart element. 46 00:03:20,080 --> 00:03:23,710 And this element is going to be the. 47 00:03:24,650 --> 00:03:25,210 Kinkier. 48 00:03:25,250 --> 00:03:30,430 So we have the spade king here. 49 00:03:30,440 --> 00:03:31,670 Actually, let's make this. 50 00:03:33,150 --> 00:03:36,540 However, in this case, we don't have any relations between these cards. 51 00:03:37,110 --> 00:03:40,080 In this cartoons, we choose the suit as a spade. 52 00:03:40,080 --> 00:03:44,200 And in card elements, we choose the element as king. 53 00:03:44,220 --> 00:03:47,460 So actually it always contains integer constant. 54 00:03:47,460 --> 00:03:52,380 So the string we put in the element is the constant name only. 55 00:03:52,380 --> 00:03:56,460 So the first element holds the value zero. 56 00:03:56,820 --> 00:03:58,470 So let's fix that again. 57 00:03:58,740 --> 00:04:01,770 Also for the first element holds our value zero. 58 00:04:02,130 --> 00:04:09,640 And here one, two, two and three. 59 00:04:09,660 --> 00:04:12,240 So here the Diamond Club is zero. 60 00:04:12,240 --> 00:04:17,600 Diamond one, fourth is for two and spades three. 61 00:04:17,610 --> 00:04:19,530 And the same applies here. 62 00:04:19,680 --> 00:04:20,700 The ace. 63 00:04:20,730 --> 00:04:22,890 One, two, three. 64 00:04:23,920 --> 00:04:24,220 Who'd. 65 00:04:25,320 --> 00:04:31,320 Three, four, five, six, seven. 66 00:04:32,330 --> 00:04:33,320 Eight. 67 00:04:33,860 --> 00:04:34,940 Nine. 68 00:04:35,950 --> 00:04:36,700 Ten. 69 00:04:38,280 --> 00:04:42,510 And 11 and 1212 signs. 70 00:04:42,510 --> 00:04:43,650 We have 13 here. 71 00:04:43,650 --> 00:04:45,000 This starts with zero signs. 72 00:04:45,000 --> 00:04:46,500 We now have. 73 00:04:46,500 --> 00:04:54,150 The 13th element in our logic is in programming and in logic is the 12 elements. 74 00:04:54,150 --> 00:04:56,310 So now here. 75 00:04:57,330 --> 00:05:03,540 Now let's create a program that will generate a random card and we can borrow the. 76 00:05:04,740 --> 00:05:07,630 Uh, generate random number function now. 77 00:05:07,650 --> 00:05:10,440 But so actually, you can. 78 00:05:12,090 --> 00:05:22,130 You can also assign a specific value to here elements, but we will discuss about that in next lectures. 79 00:05:22,140 --> 00:05:24,510 So now we're going to create here. 80 00:05:25,450 --> 00:05:30,130 The new function named the Get with String. 81 00:05:30,130 --> 00:05:33,490 But first we need to include our. 82 00:05:34,640 --> 00:05:35,480 Libraries. 83 00:05:35,480 --> 00:05:38,880 So now include the stream. 84 00:05:38,930 --> 00:05:42,050 Your stream here include. 85 00:05:42,800 --> 00:05:54,380 Include the stdlib here include and include the C time C time here. 86 00:05:54,980 --> 00:05:56,420 So now. 87 00:05:57,460 --> 00:05:59,050 We will develop our. 88 00:06:01,630 --> 00:06:02,350 Function here. 89 00:06:02,350 --> 00:06:05,680 So now String is going to return the string. 90 00:06:05,710 --> 00:06:09,670 Type here and get sweet. 91 00:06:10,240 --> 00:06:11,590 String here. 92 00:06:11,590 --> 00:06:13,120 And card. 93 00:06:14,130 --> 00:06:17,520 Card sweets and it's going to be a suite here. 94 00:06:18,420 --> 00:06:20,460 And let's make this here. 95 00:06:20,460 --> 00:06:22,580 So as you can see, we got an error here. 96 00:06:22,590 --> 00:06:23,400 Change? 97 00:06:23,520 --> 00:06:23,730 Yeah. 98 00:06:23,730 --> 00:06:27,240 We also need to use the namespace STD. 99 00:06:27,570 --> 00:06:32,700 Unless we don't want to write the STD at every declaration like this. 100 00:06:32,700 --> 00:06:35,160 So we will use a namespace. 101 00:06:35,160 --> 00:06:39,300 So you learned about the namespace in previous lectures. 102 00:06:39,300 --> 00:06:42,300 So using namespace std. 103 00:06:43,620 --> 00:06:46,890 And here, let's actually close this for now. 104 00:06:46,890 --> 00:06:47,670 Here. 105 00:06:51,190 --> 00:06:52,180 Now Cod. 106 00:06:52,180 --> 00:06:53,530 Sweet, sweet here. 107 00:06:53,530 --> 00:06:57,070 And now we're going to create a new string. 108 00:06:58,210 --> 00:06:59,500 String s. 109 00:07:00,520 --> 00:07:01,780 And switch. 110 00:07:03,640 --> 00:07:04,780 Sudhir. 111 00:07:06,250 --> 00:07:12,580 And in this case, we're going to use the switch and case condition here and here case. 112 00:07:12,970 --> 00:07:15,850 In this case, is the club then s. 113 00:07:18,360 --> 00:07:20,160 As equals of. 114 00:07:20,340 --> 00:07:21,090 Not like this. 115 00:07:21,090 --> 00:07:21,530 Yeah. 116 00:07:21,870 --> 00:07:25,980 Case club as equals club here. 117 00:07:26,250 --> 00:07:28,820 And this in case it's. 118 00:07:28,830 --> 00:07:31,350 And after that, of course, we're going to break it. 119 00:07:32,400 --> 00:07:34,590 Case Diamond. 120 00:07:37,490 --> 00:07:38,450 We're going to make. 121 00:07:38,450 --> 00:07:41,510 This is here, Diamond. 122 00:07:44,690 --> 00:07:48,800 Here and break is hurt. 123 00:07:52,090 --> 00:07:54,190 As 30 year. 124 00:07:58,840 --> 00:08:00,460 As heard here. 125 00:08:02,430 --> 00:08:03,270 Break again. 126 00:08:03,270 --> 00:08:06,190 And lastly case spade. 127 00:08:07,920 --> 00:08:08,820 Spade. 128 00:08:09,780 --> 00:08:10,440 Yeah. 129 00:08:10,470 --> 00:08:12,390 Case Spade. 130 00:08:15,140 --> 00:08:18,990 Here and here equals spade. 131 00:08:20,610 --> 00:08:22,520 And then break again. 132 00:08:22,560 --> 00:08:23,790 And after that? 133 00:08:23,790 --> 00:08:28,170 After this, the switch case statement completes. 134 00:08:28,200 --> 00:08:37,500 We will return our string return s, And in this case, as you can see here, this returns here and 135 00:08:37,500 --> 00:08:40,670 we will use get used with string here. 136 00:08:40,680 --> 00:08:48,750 So now we also need to get so here this was the get switch string which relates the card suits gave 137 00:08:48,750 --> 00:08:55,800 here like this card suits and now we need to write our card elements function. 138 00:08:55,800 --> 00:08:58,710 So now we're going to go down after the card suits. 139 00:08:58,710 --> 00:09:01,500 We're going to create the card elements function. 140 00:09:01,770 --> 00:09:03,900 So now the string. 141 00:09:05,200 --> 00:09:08,650 Get element string here. 142 00:09:09,940 --> 00:09:13,000 And here, let me fix this. 143 00:09:13,000 --> 00:09:13,360 Yeah. 144 00:09:14,080 --> 00:09:15,700 Get element, string. 145 00:09:15,730 --> 00:09:18,940 Card elements and element. 146 00:09:19,390 --> 00:09:22,330 So now we're going to write it like this again. 147 00:09:22,330 --> 00:09:24,210 We're going to create a new string. 148 00:09:24,220 --> 00:09:30,400 String E here, and then we're going to switch case statement, create here. 149 00:09:30,400 --> 00:09:31,690 Now switch. 150 00:09:33,390 --> 00:09:34,920 It's going to be element. 151 00:09:35,160 --> 00:09:46,260 And now we will write our code like this case ace the equals ace here and then break. 152 00:09:48,150 --> 00:09:49,380 Face to. 153 00:09:54,320 --> 00:09:56,810 Actually, we can also copy this. 154 00:10:00,440 --> 00:10:01,480 One, two. 155 00:10:01,490 --> 00:10:02,700 So it's an easy way. 156 00:10:02,720 --> 00:10:10,220 One, two, three, four, five, six, seven, eight, nine, ten, 11. 157 00:10:11,630 --> 00:10:12,980 No such thing here. 158 00:10:13,310 --> 00:10:15,200 So the first is Ace. 159 00:10:15,230 --> 00:10:22,010 Now we have the two also change to and then we have three. 160 00:10:23,520 --> 00:10:25,320 That's what we have three here. 161 00:10:27,470 --> 00:10:30,170 Then we have four. 162 00:10:31,910 --> 00:10:33,710 For us. 163 00:10:33,710 --> 00:10:35,540 We have four here. 164 00:10:35,630 --> 00:10:37,460 Then we have five. 165 00:10:38,030 --> 00:10:40,220 Also, we have five here. 166 00:10:40,850 --> 00:10:42,590 Then we have six. 167 00:10:43,760 --> 00:10:45,680 Also, we have six here. 168 00:10:46,370 --> 00:10:47,900 Then we have seven. 169 00:10:49,090 --> 00:10:50,950 Also, we have seven here. 170 00:10:51,520 --> 00:10:52,930 Then we have eight. 171 00:10:53,800 --> 00:10:55,630 Also, we have eight here. 172 00:10:56,770 --> 00:10:57,730 Nine? 173 00:10:59,200 --> 00:11:00,910 Also, we have nine here. 174 00:11:03,490 --> 00:11:04,930 Since we don't have ten here. 175 00:11:04,930 --> 00:11:05,350 Yeah. 176 00:11:05,500 --> 00:11:06,820 Yeah, we have ten. 177 00:11:07,830 --> 00:11:09,300 Now an. 178 00:11:12,130 --> 00:11:14,320 We would also have ten here. 179 00:11:14,860 --> 00:11:19,150 So now we comes Jack, Queen and King. 180 00:11:21,190 --> 00:11:22,030 Jack. 181 00:11:26,210 --> 00:11:27,290 Queen. 182 00:11:30,100 --> 00:11:31,340 And King. 183 00:11:31,360 --> 00:11:32,260 Lastly. 184 00:11:32,800 --> 00:11:33,610 King. 185 00:11:35,260 --> 00:11:35,590 Oops. 186 00:11:38,450 --> 00:11:39,320 Kink here. 187 00:11:40,590 --> 00:11:45,270 So now we're going to generate a random number here. 188 00:11:45,990 --> 00:11:52,100 So here now we're going to create a new function after that and name it. 189 00:11:52,110 --> 00:11:59,560 So this is random number generator will use the will return the integer number here, generate random 190 00:11:59,560 --> 00:12:03,060 numbers, generate random number. 191 00:12:03,330 --> 00:12:11,670 And this is going to be integer a minimum here, integer minimum here and integer maximum. 192 00:12:12,900 --> 00:12:14,790 Let me check the lecture time. 193 00:12:16,840 --> 00:12:17,380 Here. 194 00:12:17,590 --> 00:12:18,940 So now. 195 00:12:22,350 --> 00:12:25,410 We're going to create the here and now. 196 00:12:25,410 --> 00:12:25,890 We're going to. 197 00:12:26,280 --> 00:12:33,030 So we will use static, constant double because of the efficiency. 198 00:12:33,030 --> 00:12:36,770 And so we will only calculate this value once. 199 00:12:36,780 --> 00:12:45,600 So here we're going to create a static constant that and this will also be a double the fraction is 200 00:12:45,600 --> 00:12:52,800 going to be double fraction is going to be 1.0. 201 00:12:54,440 --> 00:13:01,250 Divide by static cast, and it's going to be the double here. 202 00:13:04,100 --> 00:13:08,570 And this novel is going to be around Max and. 203 00:13:09,550 --> 00:13:11,800 After that, we're going to plus. 204 00:13:12,550 --> 00:13:13,990 1.0. 205 00:13:15,960 --> 00:13:16,890 Here. 206 00:13:17,070 --> 00:13:25,150 Now, after that, we will need to evenly distribute the random number across our range. 207 00:13:25,170 --> 00:13:32,400 So we will return return mean plus static cast integer. 208 00:13:33,180 --> 00:13:34,590 And here. 209 00:13:35,970 --> 00:13:44,100 The max minus one plus one multiply by. 210 00:13:46,390 --> 00:13:46,800 Oops. 211 00:13:46,810 --> 00:13:47,170 Um. 212 00:13:47,710 --> 00:13:48,370 Yeah. 213 00:13:49,030 --> 00:13:49,420 Here. 214 00:13:49,420 --> 00:13:51,850 We need to also add this. 215 00:13:51,850 --> 00:13:54,280 And here. 216 00:13:55,240 --> 00:13:56,620 Multiply by. 217 00:13:58,940 --> 00:14:03,740 The rant and we will multiply rant by our fraction. 218 00:14:05,010 --> 00:14:05,610 Here. 219 00:14:06,510 --> 00:14:14,310 So now we have completed our application and in the next lecture we will write the main function here. 220 00:14:14,310 --> 00:14:16,560 So I'm waiting you in next lecture. 221 00:14:16,590 --> 00:14:17,160 See you.