WEBVTT 1 00:00:02.208 --> 00:00:04.728 Okay, so here's where it gets interesting 2 00:00:04.728 --> 00:00:06.368 when we look at extending this class 3 00:00:06.368 --> 00:00:08.328 that we created in the previous video. 4 00:00:08.328 --> 00:00:11.979 I'm talking about the enemy class. 5 00:00:11.979 --> 00:00:14.909 So let's talk about having specific types of enemies 6 00:00:14.909 --> 00:00:15.843 because the code work 7 00:00:15.843 --> 00:00:17.484 that we've currently got in that enemy class 8 00:00:17.484 --> 00:00:20.232 is of a very generic nature as you can see here. 9 00:00:20.232 --> 00:00:21.772 So let's assume that we've got several 10 00:00:21.772 --> 00:00:23.424 different types of enemies. 11 00:00:23.424 --> 00:00:26.365 For example, let's start off and create a new class 12 00:00:26.365 --> 00:00:28.333 and we're gonna call that one troll. 13 00:00:28.333 --> 00:00:31.384 Now one of the enemies our player will have to face 14 00:00:31.384 --> 00:00:32.864 will be a troll. 15 00:00:32.864 --> 00:00:35.064 Now the reason we've been using a separate file 16 00:00:35.064 --> 00:00:37.153 for our player and enemy classes 17 00:00:37.153 --> 00:00:41.003 is to make it easier to switch between them in IntelliJ 18 00:00:41.003 --> 00:00:42.833 so that we can examine the code 19 00:00:42.833 --> 00:00:45.533 without having to scroll around too much. 20 00:00:45.533 --> 00:00:46.824 Now there's not actually much code 21 00:00:46.824 --> 00:00:48.885 in this enemy class at the moment 22 00:00:48.885 --> 00:00:51.285 and troll is gonna be a subclass of enemy 23 00:00:51.285 --> 00:00:53.664 so what I'm going to do is put our new troll class 24 00:00:53.664 --> 00:00:57.075 in the enemy.py file which I've got activated now 25 00:00:57.075 --> 00:00:59.372 along with the enemy class. 26 00:00:59.372 --> 00:01:01.464 Now the Python style guide recommends 27 00:01:01.464 --> 00:01:04.384 leaving two blank lines between classes. 28 00:01:04.384 --> 00:01:08.754 So therefore, I'm going to actually start on line 20. 29 00:01:08.754 --> 00:01:11.421 All right, so class Troll Enemy. 30 00:01:16.944 --> 00:01:18.485 So that looks a bit different. 31 00:01:18.485 --> 00:01:20.551 What have I actually done here? 32 00:01:20.551 --> 00:01:23.270 Well, as I've said that troll would inherit from enemy, 33 00:01:23.270 --> 00:01:24.231 you've probably guessed 34 00:01:24.231 --> 00:01:27.002 that this is how you create a subclass. 35 00:01:27.002 --> 00:01:29.231 Now a subclass remember is a class 36 00:01:29.231 --> 00:01:32.212 that inherits from another class. 37 00:01:32.212 --> 00:01:33.671 Now you may also hear it described 38 00:01:33.671 --> 00:01:36.391 that troll extends the enemy class, 39 00:01:36.391 --> 00:01:38.522 they both mean the same thing. 40 00:01:38.522 --> 00:01:42.431 Now in fact, our enemy class is itself a subclass 41 00:01:42.431 --> 00:01:44.971 and that's because each class in Python 3 42 00:01:44.971 --> 00:01:49.201 ultimately inherits from a built-in class called object. 43 00:01:49.201 --> 00:01:52.532 Now we haven't specified that on line one, 44 00:01:52.532 --> 00:01:54.644 but we declared the enemy class 45 00:01:54.644 --> 00:01:57.452 and that's because Python 3 allows a shortcut 46 00:01:57.452 --> 00:02:00.394 for a class that has no super class other than object 47 00:02:00.394 --> 00:02:03.663 so a class, in other words, inherits directly from object. 48 00:02:03.663 --> 00:02:07.292 So in Python 3, we've got on line one this class enemy. 49 00:02:07.292 --> 00:02:10.433 I'm just gonna comment that out. 50 00:02:10.433 --> 00:02:12.633 That's exactly the same as typing it this way, 51 00:02:12.633 --> 00:02:14.216 class Enemy object. 52 00:02:17.863 --> 00:02:20.632 So both declarations do exactly the same thing. 53 00:02:20.632 --> 00:02:24.924 They define a class called enemy that inherits from object. 54 00:02:24.924 --> 00:02:27.873 Now the reason I've been saying in Python 3 55 00:02:27.873 --> 00:02:30.713 is because this wasn't the case in Python 2. 56 00:02:30.713 --> 00:02:34.113 Now in Python 2, that commented out declaration 57 00:02:34.113 --> 00:02:37.903 would produce an old style class that behaves differently 58 00:02:37.903 --> 00:02:42.023 to the new style classes you get by subclassing object. 59 00:02:42.023 --> 00:02:46.512 However, in Python 3, there are only the new style classes 60 00:02:46.512 --> 00:02:48.811 and they automatically inherit from object 61 00:02:48.811 --> 00:02:50.810 even if you don't specify it 62 00:02:50.810 --> 00:02:52.892 so even if you use a commented out form 63 00:02:52.892 --> 00:02:54.873 in other words on line one. 64 00:02:54.873 --> 00:02:57.062 Now this is a Python 3 course 65 00:02:57.062 --> 00:02:59.372 so we're not really interested in the difference, 66 00:02:59.372 --> 00:03:01.252 but I wanted to make you aware of it 67 00:03:01.252 --> 00:03:03.713 so that you always use the second form 68 00:03:03.713 --> 00:03:07.782 with object in parenthesis if you have to use Python 2 69 00:03:07.782 --> 00:03:10.023 and wanna use the new style classes. 70 00:03:10.023 --> 00:03:11.383 For that reason, it might be worthwhile 71 00:03:11.383 --> 00:03:14.382 developing the habit of always using the second form. 72 00:03:14.382 --> 00:03:17.143 Of course, if you find yourself working on Python 2 code 73 00:03:17.143 --> 00:03:20.303 that uses the first form of the class without object, 74 00:03:20.303 --> 00:03:21.952 then don't go refactoring it 75 00:03:21.952 --> 00:03:24.193 without a great deal of thought. 76 00:03:24.193 --> 00:03:25.532 In Python 2, you could change 77 00:03:25.532 --> 00:03:27.732 the entire behaviour of the programme 78 00:03:27.732 --> 00:03:31.651 just by changing class enemy as I've got on line one here, 79 00:03:31.651 --> 00:03:32.484 up here at the top here, 80 00:03:32.484 --> 00:03:34.862 to line two class Enemy object, 81 00:03:34.862 --> 00:03:36.422 but again that's Python 2. 82 00:03:36.422 --> 00:03:38.770 Not a problem with Python 3 83 00:03:38.770 --> 00:03:40.782 which we're using in this course. 84 00:03:40.782 --> 00:03:42.970 Okay, so back to troll, 85 00:03:42.970 --> 00:03:45.982 so our troll class will inherit from enemy 86 00:03:45.982 --> 00:03:49.817 and it'll have to access or have access to the attributes 87 00:03:49.817 --> 00:03:51.659 that we defined in enemy. 88 00:03:51.659 --> 00:03:54.870 The takeout is called damage method for example. 89 00:03:54.870 --> 00:03:57.280 Now we really should write a constructor, 90 00:03:57.280 --> 00:03:59.510 the init method for this troll class, 91 00:03:59.510 --> 00:04:02.529 but let's start by saying what happens if we don't. 92 00:04:02.529 --> 00:04:05.552 Now the first thing that's happening is we've got an error, 93 00:04:05.552 --> 00:04:07.221 indent expected, 94 00:04:07.221 --> 00:04:09.632 and that's because Python expects there to be some code 95 00:04:09.632 --> 00:04:11.602 after the class declaration, 96 00:04:11.602 --> 00:04:14.502 but we don't wanna provide any just yet. 97 00:04:14.502 --> 00:04:16.820 Now fortunately, there's a very useful command 98 00:04:16.820 --> 00:04:19.563 called pass that doesn't do anything 99 00:04:19.563 --> 00:04:22.313 so I can just type that in there. 100 00:04:24.122 --> 00:04:26.062 So pass doesn't do anything at all, 101 00:04:26.062 --> 00:04:27.443 but unlike a comment, 102 00:04:27.443 --> 00:04:29.832 it doesn't get ignored by the compiler. 103 00:04:29.832 --> 00:04:32.663 So by including it in instruction that does nothing, 104 00:04:32.663 --> 00:04:34.672 we've removed the syntax error 105 00:04:34.672 --> 00:04:38.294 and our code will ultimately be able to run. 106 00:04:38.294 --> 00:04:41.304 Now it may seem strange that an instruction to do nothing 107 00:04:41.304 --> 00:04:42.704 is very useful, 108 00:04:42.704 --> 00:04:46.443 but you'll come across pass in all sorts of places. 109 00:04:46.443 --> 00:04:49.232 Now you may wanna catch an error, an exception, 110 00:04:49.232 --> 00:04:51.872 that we've covered in section 13 111 00:04:51.872 --> 00:04:53.723 to prevent the programme crashing, 112 00:04:53.723 --> 00:04:56.584 but don't wanna do anything if the error happens. 113 00:04:56.584 --> 00:05:00.103 For example, if your programme is reading a load of data 114 00:05:00.103 --> 00:05:02.722 that was provided by people completing the survey, 115 00:05:02.722 --> 00:05:04.711 you may have to convert their date of birth 116 00:05:04.711 --> 00:05:06.624 into a valid Python date. 117 00:05:06.624 --> 00:05:09.161 Now some people would rather not give their date of birth, 118 00:05:09.161 --> 00:05:11.344 so that particular field could be blank. 119 00:05:11.344 --> 00:05:12.533 So you could trap the error 120 00:05:12.533 --> 00:05:16.072 when the code tries to convert no input into a date, 121 00:05:16.072 --> 00:05:18.152 but there's no action that needs to be taken, 122 00:05:18.152 --> 00:05:19.910 you just wanna skip that field 123 00:05:19.910 --> 00:05:24.024 and continue passing or continue processing the data. 124 00:05:24.024 --> 00:05:26.064 So that's a good time to use pass 125 00:05:26.064 --> 00:05:27.392 so that you can catch the error 126 00:05:27.392 --> 00:05:29.832 but continue without doing anything. 127 00:05:29.832 --> 00:05:31.923 So you can find more information on pass 128 00:05:31.923 --> 00:05:33.392 in the documentation. 129 00:05:33.392 --> 00:05:34.974 But rather than give you a link this time, 130 00:05:34.974 --> 00:05:37.504 I'm gonna show you one thing that may be confusing 131 00:05:37.504 --> 00:05:39.973 when you search for Python documentation 132 00:05:39.973 --> 00:05:42.071 using a search engine. 133 00:05:42.071 --> 00:05:43.904 So if I open a browser 134 00:05:45.382 --> 00:05:48.299 and do a search for pass in Python, 135 00:05:51.763 --> 00:05:53.542 we've got stack overflow tutorials, 136 00:05:53.542 --> 00:05:55.582 important stack flow, et cetera, 137 00:05:55.582 --> 00:05:57.363 but I suggest always starting with links 138 00:05:57.363 --> 00:05:59.683 to the Python documentation. 139 00:05:59.683 --> 00:06:01.752 But with that said, you'll often find references 140 00:06:01.752 --> 00:06:04.981 when you're searching for general Python information 141 00:06:04.981 --> 00:06:07.083 to links that are Python 2.7, 142 00:06:07.083 --> 00:06:09.883 as is the case in this fourth link here, 143 00:06:09.883 --> 00:06:12.900 and obviously we want the Python 3 documentation. 144 00:06:12.900 --> 00:06:16.071 Now the Python 2 documentation tends to be returned 145 00:06:16.071 --> 00:06:18.432 because of the way the document is organised 146 00:06:18.432 --> 00:06:21.051 so click the link anyway 147 00:06:21.051 --> 00:06:24.112 and ignore the fact that it's for Python 2. 148 00:06:24.112 --> 00:06:25.260 Then not surprisingly, 149 00:06:25.260 --> 00:06:28.032 we get the documentation coming up for Python 2, 150 00:06:28.032 --> 00:06:29.614 2.7 in this case, 151 00:06:29.614 --> 00:06:32.608 but as you can see up in the top left is a dropdown 152 00:06:32.608 --> 00:06:34.749 that lets you choose which version of Python 153 00:06:34.749 --> 00:06:36.069 you're interested in. 154 00:06:36.069 --> 00:06:38.836 So you can choose 3.5 from there 155 00:06:38.836 --> 00:06:41.086 and I recommend you do that 156 00:06:42.117 --> 00:06:43.749 to make sure the information you're getting 157 00:06:43.749 --> 00:06:45.448 is for the right version. 158 00:06:45.448 --> 00:06:46.699 So don't rule out those links 159 00:06:46.699 --> 00:06:49.116 because they mention the earlier version of Python. 160 00:06:49.116 --> 00:06:51.636 Once you get to the docs.python.org site 161 00:06:51.636 --> 00:06:53.499 like where we are now, 162 00:06:53.499 --> 00:06:55.597 you can still choose the version of Python 163 00:06:55.597 --> 00:06:57.326 that you're interested in. 164 00:06:57.326 --> 00:06:59.549 Now Python 3.6 haven't been released 165 00:06:59.549 --> 00:07:01.448 at the time of recording this video, 166 00:07:01.448 --> 00:07:04.048 but what it is you'll be able to get the documentation 167 00:07:04.048 --> 00:07:06.428 for that version from here as well. 168 00:07:06.428 --> 00:07:09.717 The same for Python 3.7 which is still in development. 169 00:07:09.717 --> 00:07:12.528 Okay, back to our main programme, 170 00:07:12.528 --> 00:07:14.248 so I'm gonna go back to main 171 00:07:14.248 --> 00:07:18.868 and what we need to do now is import enemy and troll 172 00:07:18.868 --> 00:07:21.829 without having to qualify them with a module name 173 00:07:21.829 --> 00:07:24.077 so that we don't have to write enemy.troll 174 00:07:24.077 --> 00:07:26.328 whenever we wanna create a new troll instance. 175 00:07:26.328 --> 00:07:28.755 So I can put from enemy import Enemy 176 00:07:28.755 --> 00:07:31.216 and we can just put a comma 177 00:07:31.216 --> 00:07:32.049 Troll 178 00:07:33.045 --> 00:07:35.032 and we're getting that warning because it's unused 179 00:07:35.032 --> 00:07:37.902 but that we're going to change shortly. 180 00:07:37.902 --> 00:07:39.953 Now we don't really wanna use the enemy class anymore, 181 00:07:39.953 --> 00:07:41.233 but before I delete it, 182 00:07:41.233 --> 00:07:44.014 I just wanted to show you how to import several classes 183 00:07:44.014 --> 00:07:45.734 from the same module. 184 00:07:45.734 --> 00:07:49.252 All right, so let's go down here on line 15 185 00:07:49.252 --> 00:07:52.752 and we'll put ugly_troll is equal to Troll 186 00:07:55.979 --> 00:08:00.146 then we gotta do print Ugly troll replacement field 187 00:08:03.489 --> 00:08:05.072 .format ugly_troll. 188 00:08:08.259 --> 00:08:09.676 Okay, we run that 189 00:08:11.761 --> 00:08:12.641 and we can see down at the bottom, 190 00:08:12.641 --> 00:08:14.329 the ugly troll printout 191 00:08:14.329 --> 00:08:16.921 or the ugly troll information is being displayed, 192 00:08:16.921 --> 00:08:18.569 but it's not too good at the moment though. 193 00:08:18.569 --> 00:08:20.978 The name is still enemy as you can see 194 00:08:20.978 --> 00:08:22.790 in the output down at the bottom 195 00:08:22.790 --> 00:08:24.640 and the troll has got no hit points 196 00:08:24.640 --> 00:08:25.929 so it's probably not gonna be 197 00:08:25.929 --> 00:08:28.228 a very challenging enemy to fight. 198 00:08:28.228 --> 00:08:30.059 Now we didn't add an init method 199 00:08:30.059 --> 00:08:31.801 so creating a troll like this 200 00:08:31.801 --> 00:08:35.201 uses the default values for the enemy class. 201 00:08:35.201 --> 00:08:38.390 Now the enemy class init method takes three arguments 202 00:08:38.390 --> 00:08:40.209 so we can create another troll 203 00:08:40.209 --> 00:08:43.590 and pass some values to the constructor. 204 00:08:43.590 --> 00:08:46.377 All right, so let's remove the code that created our enemy 205 00:08:46.377 --> 00:08:48.310 so we're just working with trolls now. 206 00:08:48.310 --> 00:08:51.747 So I'm gonna delete all this right up to there 207 00:08:51.747 --> 00:08:54.500 because we don't need the enemy anymore 208 00:08:54.500 --> 00:08:58.247 and then we'll add another troll as well 209 00:08:58.247 --> 00:09:02.414 so we'll put another_troll is equal to Troll Ug, 18, 1 210 00:09:08.609 --> 00:09:12.192 and we'll do a printout print another_troll 211 00:09:13.908 --> 00:09:18.075 replacement field so no output .format and another_troll. 212 00:09:22.518 --> 00:09:26.209 So this time I've created another troll with the name Ug 213 00:09:26.209 --> 00:09:29.636 that takes or has 18 hit points. 214 00:09:29.636 --> 00:09:33.169 All right, so let's create another troll, Ug's brother, 215 00:09:33.169 --> 00:09:37.336 he's called Urg so we'll call it brother equals Troll, 216 00:09:42.079 --> 00:09:44.929 we'll call him Urg and this guy's a bit of a brute 217 00:09:44.929 --> 00:09:46.631 even by troll standards 218 00:09:46.631 --> 00:09:48.868 and he can take 23 hit points and damage 219 00:09:48.868 --> 00:09:52.368 so let's set that to 23 and print brother. 220 00:09:55.300 --> 00:09:57.479 Now if you're used to overloaded constructors 221 00:09:57.479 --> 00:09:59.380 in languages such as Java, 222 00:09:59.380 --> 00:10:01.146 then you'd probably be quite happy 223 00:10:01.146 --> 00:10:02.519 with what's going on here, 224 00:10:02.519 --> 00:10:05.769 even if you can't quite work out how Python is doing it. 225 00:10:05.769 --> 00:10:07.180 But if you've never used another language, 226 00:10:07.180 --> 00:10:09.858 then this might be a bit confusing what I've just done. 227 00:10:09.858 --> 00:10:12.268 So when you overload a method 228 00:10:12.268 --> 00:10:13.929 in other programming languages, 229 00:10:13.929 --> 00:10:16.729 you provide a method with exactly the same name 230 00:10:16.729 --> 00:10:19.188 but taking different arguments. 231 00:10:19.188 --> 00:10:23.168 So the ugly troll constructor on line three 232 00:10:23.168 --> 00:10:24.988 doesn't take any arguments 233 00:10:24.988 --> 00:10:28.559 and another_troll constructor on line six 234 00:10:28.559 --> 00:10:30.689 takes or gets three arguments 235 00:10:30.689 --> 00:10:33.699 and his brother Urg on line nine 236 00:10:33.699 --> 00:10:35.588 and he has two arguments. 237 00:10:35.588 --> 00:10:38.308 Now in Java, you'd need to write three constructors, 238 00:10:38.308 --> 00:10:40.239 one for each case. 239 00:10:40.239 --> 00:10:42.239 However, Python doesn't have the concept 240 00:10:42.239 --> 00:10:44.208 of overloaded methods. 241 00:10:44.208 --> 00:10:45.519 Now if you try, 242 00:10:45.519 --> 00:10:47.777 the last method that you defined in the code 243 00:10:47.777 --> 00:10:50.316 will be the only one that exists. 244 00:10:50.316 --> 00:10:53.407 Now if you haven't used another object oriented language, 245 00:10:53.407 --> 00:10:55.154 then don't worry about that last bit, 246 00:10:55.154 --> 00:10:56.976 overloaded methods and so forth, 247 00:10:56.976 --> 00:10:58.817 because Python doesn't have them 248 00:10:58.817 --> 00:11:01.268 and I'm gonna be explaining how all this is working 249 00:11:01.268 --> 00:11:02.176 in a minute. 250 00:11:02.176 --> 00:11:05.167 But for those who have come from other languages 251 00:11:05.167 --> 00:11:08.226 and thinking this looks like method overloading, 252 00:11:08.226 --> 00:11:09.566 it actually isn't, 253 00:11:09.566 --> 00:11:12.788 but it is how you achieve the same thing in Python. 254 00:11:12.788 --> 00:11:15.708 All we've done here is use optional name to parameters 255 00:11:15.708 --> 00:11:18.365 in the enemy class init method. 256 00:11:18.365 --> 00:11:20.716 And it's really now different from using the print method 257 00:11:20.716 --> 00:11:23.967 to print things out because on line 10, 258 00:11:23.967 --> 00:11:25.567 we print brother 259 00:11:25.567 --> 00:11:28.367 and that's the only argument we provided to the function. 260 00:11:28.367 --> 00:11:30.387 Printout does take other arguments 261 00:11:30.387 --> 00:11:33.668 so you could specify that there's no end of line character 262 00:11:33.668 --> 00:11:34.886 for example. 263 00:11:34.886 --> 00:11:36.897 So I'm gonna come along here. 264 00:11:36.897 --> 00:11:40.868 Actually, let's do it on line seven, so another_troll, 265 00:11:40.868 --> 00:11:41.959 and you save this before encoding 266 00:11:41.959 --> 00:11:45.466 and equals and two double quotes, 267 00:11:45.466 --> 00:11:47.239 an empty string in other words, 268 00:11:47.239 --> 00:11:48.822 so when we do that, 269 00:11:50.457 --> 00:11:53.988 we find the another_troll Urg and his brother argument 270 00:11:53.988 --> 00:11:56.827 and his brother Urg are now printed on the same line 271 00:11:56.827 --> 00:11:58.788 because we've removed the end of line 272 00:11:58.788 --> 00:12:01.325 or replaced that with an empty string. 273 00:12:01.325 --> 00:12:03.188 So this is not the best example 274 00:12:03.188 --> 00:12:05.598 because we have to specify the name end. 275 00:12:05.598 --> 00:12:07.437 That's because the print function 276 00:12:07.437 --> 00:12:09.788 can take any number of strings to print 277 00:12:09.788 --> 00:12:10.967 so just adding another one 278 00:12:10.967 --> 00:12:13.226 to the list of arguments wouldn't work. 279 00:12:13.226 --> 00:12:15.708 But for methods that have a fixed number of arguments, 280 00:12:15.708 --> 00:12:18.639 you can provide them without using their names 281 00:12:18.639 --> 00:12:21.308 as long as you keep them in the same position 282 00:12:21.308 --> 00:12:23.897 that they were specified originally. 283 00:12:23.897 --> 00:12:27.399 So when we don't specify any arguments on line three, 284 00:12:27.399 --> 00:12:29.078 the default values that we specified 285 00:12:29.078 --> 00:12:31.745 in enemy's init method are used. 286 00:12:33.217 --> 00:12:36.617 And you can see we've got name equals enemy, 287 00:12:36.617 --> 00:12:39.348 hit points equal zero, lives equals one. 288 00:12:39.348 --> 00:12:42.087 So obviously the default values 289 00:12:42.087 --> 00:12:46.564 are the ones that are after the equal sign on each. 290 00:12:46.564 --> 00:12:47.945 We're going back here now to main. 291 00:12:47.945 --> 00:12:51.162 On line six, all the values were specified. 292 00:12:51.162 --> 00:12:52.614 And then on line nine, 293 00:12:52.614 --> 00:12:55.716 only the two arguments were specified. 294 00:12:55.716 --> 00:13:00.093 So name in this case on line nine gets the value of Urg 295 00:13:00.093 --> 00:13:02.414 and hit points gets the value of 23 296 00:13:02.414 --> 00:13:04.492 then the lives were defaulted to one 297 00:13:04.492 --> 00:13:05.782 because of the way we have defined this 298 00:13:05.782 --> 00:13:09.603 as the default value for the lives attribute. 299 00:13:09.603 --> 00:13:11.022 So once again, 300 00:13:11.022 --> 00:13:14.404 if you are used to languages such as Java or C++, 301 00:13:14.404 --> 00:13:18.572 you can't actually overload functions and methods in Python, 302 00:13:18.572 --> 00:13:20.782 but you can generally get the same effect 303 00:13:20.782 --> 00:13:24.002 by using named parameters with default values. 304 00:13:24.002 --> 00:13:26.152 All right, so I'm gonna stop the video here. 305 00:13:26.152 --> 00:13:26.985 In the next video, 306 00:13:26.985 --> 00:13:28.881 we're going to look at making our troll class 307 00:13:28.881 --> 00:13:31.320 a little bit more useful but at the moment, 308 00:13:31.320 --> 00:13:33.433 we could do exactly the same thing 309 00:13:33.433 --> 00:13:35.732 by using the enemy class rather than a troll. 310 00:13:35.732 --> 00:13:36.565 So in other words, 311 00:13:36.565 --> 00:13:40.534 we could come back here and change that to enemy. 312 00:13:40.534 --> 00:13:42.201 And if you run that, 313 00:13:43.625 --> 00:13:45.625 we get exactly the same result. 314 00:13:45.625 --> 00:13:47.694 So although troll is a subclass of enemy, 315 00:13:47.694 --> 00:13:50.025 at the moment it's not a very useful one. 316 00:13:50.025 --> 00:13:52.114 Now in the next video, we'll make some changes 317 00:13:52.114 --> 00:13:54.596 and see the advantages of creating classes 318 00:13:54.596 --> 00:13:56.876 that inherit from another class. 319 00:13:56.876 --> 00:13:57.814 But just before I do that, 320 00:13:57.814 --> 00:14:02.314 I'm gonna remove this and equals part on line seven. 321 00:14:02.314 --> 00:14:05.081 Okay, so I'll see you in the next video.