1 00:00:06,060 --> 00:00:11,760 I hope you enjoyed this section and that you were able to complete this assignment based on the previous 2 00:00:11,760 --> 00:00:19,800 lectures and this assignment, we wanted to create an enum called Shape and provide the values of Triangle, 3 00:00:19,800 --> 00:00:22,650 Square, Pentagon and Octagon. 4 00:00:23,640 --> 00:00:30,150 Then we need to create a method for this enum that returns the number of corners each shape has based 5 00:00:30,150 --> 00:00:31,830 on the type of shape. 6 00:00:31,860 --> 00:00:38,220 So, for example, if we have a triangle, we will return three, and then if we're square, we will 7 00:00:38,220 --> 00:00:39,450 return four. 8 00:00:40,500 --> 00:00:46,760 So the first thing that we need to do is create an enum called Shape, and we need to give it some variance. 9 00:00:46,770 --> 00:00:55,020 So we are going to give it Triangle, Square, Pentagon to go on. 10 00:00:57,210 --> 00:01:01,530 Now we need to implement our method on the Shape Enum. 11 00:01:03,110 --> 00:01:07,760 And we're going to call it corners and we need to have a reference to our self. 12 00:01:08,660 --> 00:01:14,000 And then we know that we want to return how many corners we have, so we're going to return an eight. 13 00:01:15,110 --> 00:01:24,650 So now we are going to do a match on ourself and if we are a triangle we want to return three. 14 00:01:25,670 --> 00:01:36,440 If we are a square, we want to return four, and if we are a Pentagon, we want to return five. 15 00:01:37,130 --> 00:01:38,780 And then if we're an octagon. 16 00:01:38,780 --> 00:01:44,150 And since that's our only other case, we can use the underscore as our catchall. 17 00:01:44,900 --> 00:01:48,230 Then we want to return eight in that case. 18 00:01:49,870 --> 00:01:57,100 So now we will say let shape equals shape triangle and we want to verify our results. 19 00:01:57,100 --> 00:01:59,830 So we will just print them out. 20 00:02:00,670 --> 00:02:04,060 So we will say shape dot corners. 21 00:02:04,750 --> 00:02:09,280 And now we can run our code and we see that we have three. 22 00:02:09,290 --> 00:02:10,480 So that's good. 23 00:02:11,570 --> 00:02:12,880 Let's do square. 24 00:02:14,740 --> 00:02:15,750 We got four. 25 00:02:15,760 --> 00:02:16,750 So that's good. 26 00:02:16,750 --> 00:02:19,440 So we can assume Pentagon will be fine. 27 00:02:19,450 --> 00:02:23,920 So now let's check the Octagon just to verify that we get eight. 28 00:02:24,970 --> 00:02:26,320 And now we have eight. 29 00:02:26,530 --> 00:02:29,700 So that is my solution to the assignment. 30 00:02:29,710 --> 00:02:34,180 If you have any questions, please feel free to ask them in the Q&A section.