1 00:00:00,390 --> 00:00:01,170 ‫Welcome back. 2 00:00:01,200 --> 00:00:06,140 ‫In this video, we're going to look at enemies and an enemy is basically a set of constants. 3 00:00:06,150 --> 00:00:12,300 ‫It's immutable and should be placed at the namespace level so it can be used by the whole library. 4 00:00:12,300 --> 00:00:18,660 ‫And well, it's pretty much something like let's say we have days, so there are only seven days in 5 00:00:18,660 --> 00:00:19,170 ‫a week. 6 00:00:19,170 --> 00:00:27,240 ‫So we can create an enum called Day and it will contain a monday, it will contain a Tuesday or Wednesday, 7 00:00:27,300 --> 00:00:31,470 ‫Thursday, Friday, Saturday and Sunday. 8 00:00:32,370 --> 00:00:37,050 ‫So these are our days, and that's an enum. 9 00:00:37,170 --> 00:00:37,650 ‫All right. 10 00:00:37,650 --> 00:00:38,430 ‫That's already it. 11 00:00:38,430 --> 00:00:45,480 ‫So now if we want to use the day enum that we would have, it's seven values that there are and they 12 00:00:45,480 --> 00:00:46,080 ‫never change. 13 00:00:46,080 --> 00:00:46,350 ‫Right? 14 00:00:46,350 --> 00:00:48,780 ‫So you only have those seven days. 15 00:00:49,230 --> 00:00:53,580 ‫So now let's create an enum day in our main method. 16 00:00:53,580 --> 00:00:59,760 ‫So I'm going to create date and I'm going to call it f r setting for Friday and that will be day dot. 17 00:00:59,760 --> 00:01:04,650 ‫And as you can see, there are our values and they are also indexed. 18 00:01:04,650 --> 00:01:11,460 ‫So they thought Friday is equal to four, Monday is equal to zero. 19 00:01:11,490 --> 00:01:12,150 ‫All right. 20 00:01:12,150 --> 00:01:15,630 ‫So let's say I'm using Friday, so it starts at four. 21 00:01:15,680 --> 00:01:17,340 ‫It is the value of four. 22 00:01:17,640 --> 00:01:19,830 ‫Now let's create another day. 23 00:01:19,830 --> 00:01:21,330 ‫Let's say it's Sunday. 24 00:01:21,630 --> 00:01:25,680 ‫It's day dot, as you know. 25 00:01:25,680 --> 00:01:33,360 ‫Let's create another day that I'm just going to call a and a will be Friday so data FR and now let's 26 00:01:33,360 --> 00:01:42,240 ‫use the console right line to check if f r is equal to A, so if Friday is equal to our A day and we 27 00:01:42,240 --> 00:01:50,610 ‫can check that out and before we do so, we should add a console thought right key 28 00:01:53,430 --> 00:01:54,030 ‫like that. 29 00:01:54,030 --> 00:01:58,950 ‫Now let's start it again and we see it says true. 30 00:01:58,950 --> 00:02:06,330 ‫And that is because this day has the value of Friday and this day here as also the value of Friday. 31 00:02:08,280 --> 00:02:13,800 ‫We can also do something like just printing it onto the console so we can just go ahead and say something 32 00:02:13,800 --> 00:02:18,090 ‫like Day Dot Ammo standing for Monday. 33 00:02:18,510 --> 00:02:20,340 ‫Let's see what it prints onto the screen. 34 00:02:21,390 --> 00:02:24,480 ‫And we see it true and it says Monday, MO. 35 00:02:25,260 --> 00:02:28,230 ‫So Monday gave us the Monday value. 36 00:02:28,230 --> 00:02:35,580 ‫So it's just something like MO, but it's just a representation as a string and we can go ahead and 37 00:02:35,580 --> 00:02:37,260 ‫get to integer value as well. 38 00:02:37,260 --> 00:02:46,260 ‫So see w let's get the integer of day dot m o of Monday and as you know that zero because it starts 39 00:02:46,260 --> 00:02:47,160 ‫with zero. 40 00:02:47,160 --> 00:02:55,830 ‫So we get here true mo and zero because first value is zero, then we have one, two and so forth. 41 00:02:57,270 --> 00:02:58,530 ‫Now it's a little challenge. 42 00:02:58,560 --> 00:03:04,080 ‫Create an enum with the months of the year, so please go ahead and do that. 43 00:03:06,030 --> 00:03:06,780 ‫All right. 44 00:03:06,780 --> 00:03:24,570 ‫So we have Enum Month and we have January, February, March, April, May, June, July, August, 45 00:03:24,570 --> 00:03:31,080 ‫September, October, November and December. 46 00:03:33,250 --> 00:03:39,460 ‫So this is another month and now we can access those values in the same way. 47 00:03:39,460 --> 00:03:43,810 ‫And we cannot only access them in this class, but we can access them in the whole namespace because 48 00:03:43,810 --> 00:03:48,640 ‫I created them outside of this class and generally in that namespace. 49 00:03:49,180 --> 00:03:54,800 ‫Now let's say we want this to start with one, so we want Jan to be at one. 50 00:03:54,820 --> 00:04:02,200 ‫So let's just set the value of one and now let's write the value of our month. 51 00:04:02,200 --> 00:04:10,690 ‫So we're going to get month dot January or let's say we want to see if February now is actually two. 52 00:04:11,920 --> 00:04:16,060 ‫So I'm going to use an integer casting here. 53 00:04:16,060 --> 00:04:17,850 ‫So I'm going to cast that into an integer. 54 00:04:17,860 --> 00:04:18,610 ‫Let's see. 55 00:04:19,770 --> 00:04:26,170 ‫And we see February as to now, and that is because we started the index at one. 56 00:04:26,190 --> 00:04:28,770 ‫Now let's see if we can change as well. 57 00:04:28,920 --> 00:04:34,740 ‫Like July, let's say July should be now 12 because usually it would be seven the seventh month, but 58 00:04:34,740 --> 00:04:36,440 ‫let's say July is the 12 month. 59 00:04:36,450 --> 00:04:40,020 ‫So let's also print that on to the console. 60 00:04:40,560 --> 00:04:50,130 ‫So I'm going to use the same line of code like here, but I'm going to replace February with July or 61 00:04:50,130 --> 00:04:51,540 ‫actually let's say August. 62 00:04:51,750 --> 00:04:54,210 ‫Let's see what August gives us. 63 00:04:55,530 --> 00:05:02,880 ‫And we see it's 13 so we can reassign the index and it will keep on counting from that point on. 64 00:05:02,880 --> 00:05:11,010 ‫So you see June is equal to six, July equal to 12, August equal to 13 and so forth. 65 00:05:12,590 --> 00:05:21,590 ‫So generally the one thing to remember in OMS are they are to share a set of constants to keep a library 66 00:05:21,590 --> 00:05:28,400 ‫consistent so you can use them in all the different classes and they will always have the same value 67 00:05:28,400 --> 00:05:33,950 ‫and you won't have to create the constant inside of the classes all the time.