WEBVTT

00:00.700 --> 00:08.590
In this lecture I want to go over our final user defined type enemies enemies are very interesting user

00:08.590 --> 00:15.520
defined type that I find myself using all the time you DMs are enumerated values.

00:15.880 --> 00:20.470
So meaning they have a set range of values that they can be.

00:20.470 --> 00:31.050
So for example we could have an enum for the four cardinal directions so we could make our Itam here

00:33.040 --> 00:34.480
call it direction

00:38.480 --> 00:39.970
Hebei direction type

00:44.520 --> 00:47.690
in the four cardinal directions north

00:50.660 --> 00:54.570
yse south

00:57.080 --> 01:00.870
west.

01:01.000 --> 01:06.660
So we have the keyword ENM the name of our new types.

01:06.700 --> 01:08.780
It's called direction type.

01:08.780 --> 01:15.910
And inside the braces we have all the values that this eadem type can have.

01:16.000 --> 01:25.190
So namely north east south and west I usually will have all values in uppercase But this is just my

01:25.190 --> 01:26.650
convention.

01:27.670 --> 01:32.550
And notice also that I set the first one to be zero.

01:32.620 --> 01:39.410
That's because each one after it will have a value of one more than the previous one.

01:39.430 --> 01:46.100
So east here will have the value of 1 in South 2 and West 3.

01:46.180 --> 01:49.380
We don't have to set it to zero star.

01:49.490 --> 01:50.560
Use any number.

01:50.560 --> 01:55.980
But again this is my convention usually set the first one to be zero.

01:57.290 --> 02:06.530
One thing we shouldn't do is consider the values as integers outrage though often we can we should consider

02:06.530 --> 02:09.720
them part of their own type.

02:09.960 --> 02:19.040
K so our direction type can only have these four values and no other k.

02:19.060 --> 02:27.910
So like I said before we could use you namaz when we need to type with only a certain number of values.

02:28.600 --> 02:32.380
And this also helps quite a bit with readability as well.

02:32.380 --> 02:34.720
Just like typedef Stu.

02:34.750 --> 02:38.790
So we're using them quite a bit in the next game.

02:38.800 --> 02:43.180
So in the next lecture I went to do some practice.
