1 00:00:00,320 --> 00:00:06,440 Now, we will continue our program and we will write the main function here. 2 00:00:06,440 --> 00:00:10,570 So we will need to set an initial seed value to the system clock here. 3 00:00:10,580 --> 00:00:21,440 So in order to do that, as rand here, static as Rand static cast, we're going to use it static static 4 00:00:21,440 --> 00:00:21,860 cast. 5 00:00:21,950 --> 00:00:29,000 And we will into this braces here, we're going to use unsigned integer unsigned integer. 6 00:00:29,120 --> 00:00:32,060 And after that we're going to use the time. 7 00:00:32,660 --> 00:00:38,780 So the time is going to be the best is zero time, the zero. 8 00:00:38,780 --> 00:00:41,660 And then after that we will. 9 00:00:42,880 --> 00:00:46,240 Need to generate a random seed and element cart. 10 00:00:46,240 --> 00:00:47,800 So in order to do that. 11 00:00:47,830 --> 00:00:52,840 Integer rand suite or let's make it the. 12 00:00:54,360 --> 00:00:54,750 Yeah. 13 00:00:54,750 --> 00:00:57,150 My, my sweet, my sweet. 14 00:00:57,150 --> 00:01:01,380 And we will use the generate random number function here. 15 00:01:01,530 --> 00:01:07,200 Generate random function that gives us an random obviously. 16 00:01:07,200 --> 00:01:13,710 So now generate random number we will give it some 023. 17 00:01:14,620 --> 00:01:17,800 So, as you know, we have. 18 00:01:18,810 --> 00:01:22,490 From 0 to 3 card switch here. 19 00:01:22,500 --> 00:01:30,420 So in this case, it's zero one, two, three, three here. 20 00:01:30,420 --> 00:01:42,300 So our code here will generate from 0 to 3, not random number here, so zero and three. 21 00:01:43,540 --> 00:01:47,140 And after that we will also need to generate an element. 22 00:01:47,140 --> 00:01:50,080 So integer my element here. 23 00:01:50,110 --> 00:01:55,470 The generate generate generate random number here. 24 00:01:55,480 --> 00:01:57,670 Of course it's going to start with from zero. 25 00:01:57,670 --> 00:02:01,390 And let's watch actually what we need to write it here. 26 00:02:01,630 --> 00:02:08,560 So in this case it's one, two, three oh no, zero from zero. 27 00:02:08,590 --> 00:02:14,320 As you learned in previous lectures, the N starts from zero by default. 28 00:02:14,320 --> 00:02:21,100 So zero, one, two, three, four. 29 00:02:22,530 --> 00:02:23,190 Five. 30 00:02:23,680 --> 00:02:24,730 Six. 31 00:02:25,270 --> 00:02:26,290 Seven. 32 00:02:27,430 --> 00:02:28,180 Eight. 33 00:02:28,330 --> 00:02:29,440 Nine. 34 00:02:29,770 --> 00:02:30,700 Ten. 35 00:02:31,700 --> 00:02:35,510 11 and 12 here. 36 00:02:35,570 --> 00:02:37,550 So we're going to make it 12. 37 00:02:37,880 --> 00:02:42,500 So it will generate a random number from 0 to 12. 38 00:02:42,530 --> 00:02:48,010 So actually, we have some problem here, as you can see, generate. 39 00:02:48,020 --> 00:02:49,370 So we need to write it like that. 40 00:02:49,370 --> 00:02:55,420 But it's not a problem for the compiled base, but it's like looks awkward. 41 00:02:55,430 --> 00:03:02,480 So gener generate here, we refactored it and everything looks fine. 42 00:03:05,040 --> 00:03:05,670 Yeah. 43 00:03:06,300 --> 00:03:06,810 Okay. 44 00:03:07,170 --> 00:03:16,460 So now, since we have received our codes, now we need to make a static cast here. 45 00:03:16,470 --> 00:03:20,880 So here the card suits. 46 00:03:20,880 --> 00:03:24,450 So the card suits the suit. 47 00:03:24,480 --> 00:03:24,750 Here. 48 00:03:24,750 --> 00:03:32,370 We're going to use the static cast and we will use the card card elements, which is going to be we 49 00:03:32,370 --> 00:03:39,630 will pass in my my element or my suit firstly, and then we will pass my element. 50 00:03:39,750 --> 00:03:42,690 So here we have already defined it, I think. 51 00:03:42,720 --> 00:03:43,320 Yeah. 52 00:03:44,210 --> 00:03:47,210 Variable comes with an R value of card elements. 53 00:03:47,240 --> 00:03:47,960 Yeah. 54 00:03:47,990 --> 00:03:50,360 Card switch needs to be card switch. 55 00:03:50,390 --> 00:03:50,840 Of course. 56 00:03:50,840 --> 00:03:52,160 Card switch here. 57 00:03:52,160 --> 00:04:00,020 And after that we will use the card elements and element here the staticcast again and we will pass 58 00:04:00,020 --> 00:04:01,090 instead of Cardsuit. 59 00:04:01,160 --> 00:04:03,590 We will pass the card elements. 60 00:04:03,590 --> 00:04:07,250 And here, my sweet, here. 61 00:04:07,580 --> 00:04:09,080 Oops, my element. 62 00:04:09,080 --> 00:04:09,560 Oops. 63 00:04:10,280 --> 00:04:12,110 My element. 64 00:04:12,110 --> 00:04:13,340 My element. 65 00:04:17,420 --> 00:04:17,610 Hmm. 66 00:04:17,870 --> 00:04:18,520 Oh, yeah. 67 00:04:18,620 --> 00:04:20,000 Yes, We have to write it like that. 68 00:04:20,000 --> 00:04:21,680 So it's fixed. 69 00:04:22,790 --> 00:04:26,150 And now we will print this on the screen. 70 00:04:26,150 --> 00:04:29,000 So we will use a print with a C out. 71 00:04:29,030 --> 00:04:31,130 C out the. 72 00:04:31,130 --> 00:04:34,880 Your card is here. 73 00:04:37,940 --> 00:04:41,450 Your card is and we will see out again. 74 00:04:41,600 --> 00:04:43,370 Get element. 75 00:04:43,400 --> 00:04:44,990 Get element. 76 00:04:44,990 --> 00:04:45,710 String. 77 00:04:45,710 --> 00:04:48,680 And with the get element string. 78 00:04:48,710 --> 00:04:51,930 As you can see here, we need to pass some arguments in it. 79 00:04:51,950 --> 00:04:58,200 So just I'm waiting for your answer and stop this video and write your own code here. 80 00:04:58,220 --> 00:04:59,630 What we need to pass here. 81 00:04:59,630 --> 00:05:00,230 Here. 82 00:05:03,870 --> 00:05:08,190 So we need to pass here the sweet. 83 00:05:09,420 --> 00:05:14,370 So, uh, the first, of course we need to pass it element and then we will pass through it here. 84 00:05:14,370 --> 00:05:20,160 So first this goes here, the element class here, because we will get elements to string here. 85 00:05:20,280 --> 00:05:24,990 So element and here. 86 00:05:25,020 --> 00:05:27,450 See out get. 87 00:05:28,910 --> 00:05:32,480 So we need to almost make it like this. 88 00:05:32,480 --> 00:05:36,110 So our suite is off here. 89 00:05:37,970 --> 00:05:39,140 The get. 90 00:05:39,890 --> 00:05:41,660 Suet shrink. 91 00:05:42,650 --> 00:05:45,500 And obviously we need to pass here. 92 00:05:46,420 --> 00:05:47,560 The sweet variable. 93 00:05:49,080 --> 00:05:51,300 And here we will write the sweet. 94 00:05:52,790 --> 00:05:55,160 And after that, of course, end line. 95 00:05:56,790 --> 00:05:59,070 And after that we will return zero. 96 00:05:59,070 --> 00:06:00,780 So we already written it here. 97 00:06:04,170 --> 00:06:12,540 So from this code you can see that we can access the enum data using an integer value. 98 00:06:13,410 --> 00:06:13,970 Here. 99 00:06:13,980 --> 00:06:24,090 So however, we have to cast that integer value so that it can fit the enum data using the static cast. 100 00:06:24,740 --> 00:06:28,880 So and as you can see here, we did it with, like, that card. 101 00:06:28,880 --> 00:06:29,960 Sweet, sweet. 102 00:06:29,960 --> 00:06:31,330 And we write it. 103 00:06:31,340 --> 00:06:36,470 The static cast, my sweet and static cats, my element. 104 00:06:36,920 --> 00:06:40,010 So let's actually run our code here. 105 00:06:45,700 --> 00:06:49,180 To here main dot cpp. 106 00:06:50,720 --> 00:06:53,690 The output is going to be my output. 107 00:06:54,810 --> 00:06:56,070 Or let's. 108 00:06:57,110 --> 00:06:57,930 Random card. 109 00:06:57,950 --> 00:07:04,860 Random card that x here no return statements in a function return void. 110 00:07:04,880 --> 00:07:06,410 So we have. 111 00:07:07,610 --> 00:07:10,280 Error in the 81st line. 112 00:07:11,570 --> 00:07:13,640 So we need to return string. 113 00:07:14,720 --> 00:07:19,460 Yeah, we will write that return string here and everything is fine. 114 00:07:20,710 --> 00:07:21,180 Yeah. 115 00:07:21,190 --> 00:07:22,300 Not return a string. 116 00:07:22,300 --> 00:07:24,520 We need return E here. 117 00:07:24,820 --> 00:07:28,330 So return E and everything fixed here. 118 00:07:28,330 --> 00:07:29,740 And let's check it again. 119 00:07:32,560 --> 00:07:38,680 Yes, it's compiled sales cleaned here and now let's run our program. 120 00:07:38,680 --> 00:07:42,100 So as you can see that this is the random card here. 121 00:07:42,130 --> 00:07:44,770 So random card dot excel. 122 00:07:45,070 --> 00:07:49,060 So as you can see, our card is queen of spades. 123 00:07:49,060 --> 00:07:52,710 Let's seven of spade, Jack of Spade. 124 00:07:52,720 --> 00:07:54,370 Seven of spades, seven of spade. 125 00:07:54,400 --> 00:07:55,480 Jack of Spade here. 126 00:07:55,480 --> 00:07:57,910 Two of spade, Jack of Spade. 127 00:07:57,910 --> 00:08:00,370 And, uh, here. 128 00:08:05,870 --> 00:08:09,230 Let's actually let me look at the lecture time. 129 00:08:09,230 --> 00:08:12,050 So, uh, that's it for this lecture. 130 00:08:12,050 --> 00:08:15,560 And in the next lecture, we will also develop an advanced or application. 131 00:08:15,750 --> 00:08:19,160 As you can see, we got a hell all spades here. 132 00:08:19,160 --> 00:08:20,690 So that's a problem for us. 133 00:08:20,690 --> 00:08:25,460 So we will fix that in next lectures and we will develop our application further. 134 00:08:25,460 --> 00:08:27,080 So I'm waiting you in the next lecture.