1
00:00:05,320 --> 00:00:07,840
Okay, so here's where it gets interesting

2
00:00:07,840 --> 00:00:09,480
when we look at extending this class

3
00:00:09,480 --> 00:00:11,440
that we created in the previous video.

4
00:00:11,440 --> 00:00:15,090
I'm talking about the enemy class.

5
00:00:15,090 --> 00:00:18,020
So let's talk about having specific types of enemies

6
00:00:18,020 --> 00:00:18,960
because the code work

7
00:00:18,960 --> 00:00:20,600
that we've currently got in that enemy class

8
00:00:20,600 --> 00:00:23,350
is of a very generic nature as you can see here.

9
00:00:23,350 --> 00:00:24,890
So let's assume that we've got several

10
00:00:24,890 --> 00:00:26,540
different types of enemies.

11
00:00:26,540 --> 00:00:29,480
For example, let's start off and create a new class

12
00:00:29,480 --> 00:00:31,450
and we're gonna call that one troll.

13
00:00:31,450 --> 00:00:34,500
Now one of the enemies our player will have to face

14
00:00:34,500 --> 00:00:35,980
will be a troll.

15
00:00:35,980 --> 00:00:38,180
Now the reason we've been using a separate file

16
00:00:38,180 --> 00:00:40,270
for our player and enemy classes

17
00:00:40,270 --> 00:00:44,120
is to make it easier to switch between them in IntelliJ

18
00:00:44,120 --> 00:00:45,950
so that we can examine the code

19
00:00:45,950 --> 00:00:48,650
without having to scroll around too much.

20
00:00:48,650 --> 00:00:49,940
Now there's not actually much code

21
00:00:49,940 --> 00:00:52,000
in this enemy class at the moment

22
00:00:52,000 --> 00:00:54,400
and troll is gonna be a subclass of enemy

23
00:00:54,400 --> 00:00:56,780
so what I'm going to do is put our new troll class

24
00:00:56,780 --> 00:01:00,190
in the enemy.py file which I've got activated now

25
00:01:00,190 --> 00:01:02,490
along with the enemy class.

26
00:01:02,490 --> 00:01:04,580
Now the Python style guide recommends

27
00:01:04,580 --> 00:01:07,500
leaving two blank lines between classes.

28
00:01:07,500 --> 00:01:11,870
So therefore, I'm going to actually start on line 20.

29
00:01:11,870 --> 00:01:14,540
All right, so class Troll Enemy.

30
00:01:20,060 --> 00:01:21,600
So that looks a bit different.

31
00:01:21,600 --> 00:01:23,670
What have I actually done here?

32
00:01:23,670 --> 00:01:26,390
Well, as I've said that troll would inherit from enemy,

33
00:01:26,390 --> 00:01:27,350
you've probably guessed

34
00:01:27,350 --> 00:01:30,120
that this is how you create a subclass.

35
00:01:30,120 --> 00:01:32,350
Now a subclass remember is a class

36
00:01:32,350 --> 00:01:35,330
that inherits from another class.

37
00:01:35,330 --> 00:01:36,790
Now you may also hear it described

38
00:01:36,790 --> 00:01:39,510
that troll extends the enemy class,

39
00:01:39,510 --> 00:01:41,640
they both mean the same thing.

40
00:01:41,640 --> 00:01:45,550
Now in fact, our enemy class is itself a subclass

41
00:01:45,550 --> 00:01:48,090
and that's because each class in Python 3

42
00:01:48,090 --> 00:01:52,320
ultimately inherits from a built-in class called object.

43
00:01:52,320 --> 00:01:55,650
Now we haven't specified that on line one,

44
00:01:55,650 --> 00:01:57,760
but we declared the enemy class

45
00:01:57,760 --> 00:02:00,570
and that's because Python 3 allows a shortcut

46
00:02:00,570 --> 00:02:03,510
for a class that has no super class other than object

47
00:02:03,510 --> 00:02:06,780
so a class, in other words, inherits directly from object.

48
00:02:06,780 --> 00:02:10,410
So in Python 3, we've got on line one this class enemy.

49
00:02:10,410 --> 00:02:13,550
I'm just gonna comment that out.

50
00:02:13,550 --> 00:02:15,750
That's exactly the same as typing it this way,

51
00:02:15,750 --> 00:02:17,330
class Enemy object.

52
00:02:20,980 --> 00:02:23,750
So both declarations do exactly the same thing.

53
00:02:23,750 --> 00:02:28,040
They define a class called enemy that inherits from object.

54
00:02:28,040 --> 00:02:30,990
Now the reason I've been saying in Python 3

55
00:02:30,990 --> 00:02:33,830
is because this wasn't the case in Python 2.

56
00:02:33,830 --> 00:02:37,230
Now in Python 2, that commented out declaration

57
00:02:37,230 --> 00:02:41,020
would produce an old style class that behaves differently

58
00:02:41,020 --> 00:02:45,140
to the new style classes you get by subclassing object.

59
00:02:45,140 --> 00:02:49,630
However, in Python 3, there are only the new style classes

60
00:02:49,630 --> 00:02:51,930
and they automatically inherit from object

61
00:02:51,930 --> 00:02:53,930
even if you don't specify it

62
00:02:53,930 --> 00:02:56,010
so even if you use a commented out form

63
00:02:56,010 --> 00:02:57,990
in other words on line one.

64
00:02:57,990 --> 00:03:00,180
Now this is a Python 3 course

65
00:03:00,180 --> 00:03:02,490
so we're not really interested in the difference,

66
00:03:02,490 --> 00:03:04,370
but I wanted to make you aware of it

67
00:03:04,370 --> 00:03:06,830
so that you always use the second form

68
00:03:06,830 --> 00:03:10,900
with object in parenthesis if you have to use Python 2

69
00:03:10,900 --> 00:03:13,140
and wanna use the new style classes.

70
00:03:13,140 --> 00:03:14,500
For that reason, it might be worthwhile

71
00:03:14,500 --> 00:03:17,500
developing the habit of always using the second form.

72
00:03:17,500 --> 00:03:20,260
Of course, if you find yourself working on Python 2 code

73
00:03:20,260 --> 00:03:23,420
that uses the first form of the class without object,

74
00:03:23,420 --> 00:03:25,070
then don't go refactoring it

75
00:03:25,070 --> 00:03:27,310
without a great deal of thought.

76
00:03:27,310 --> 00:03:28,650
In Python 2, you could change

77
00:03:28,650 --> 00:03:30,850
the entire behaviour of the programme

78
00:03:30,850 --> 00:03:34,770
just by changing class enemy as I've got on line one here,

79
00:03:34,770 --> 00:03:35,600
up here at the top here,

80
00:03:35,600 --> 00:03:37,980
to line two class Enemy object,

81
00:03:37,980 --> 00:03:39,540
but again that's Python 2.

82
00:03:39,540 --> 00:03:41,890
Not a problem with Python 3

83
00:03:41,890 --> 00:03:43,900
which we're using in this course.

84
00:03:43,900 --> 00:03:46,090
Okay, so back to troll,

85
00:03:46,090 --> 00:03:49,100
so our troll class will inherit from enemy

86
00:03:49,100 --> 00:03:52,930
and it'll have to access or have access to the attributes

87
00:03:52,930 --> 00:03:54,770
that we defined in enemy.

88
00:03:54,770 --> 00:03:57,990
The takeout is called damage method for example.

89
00:03:57,990 --> 00:04:00,400
Now we really should write a constructor,

90
00:04:00,400 --> 00:04:02,630
the init method for this troll class,

91
00:04:02,630 --> 00:04:05,640
but let's start by saying what happens if we don't.

92
00:04:05,640 --> 00:04:08,670
Now the first thing that's happening is we've got an error,

93
00:04:08,670 --> 00:04:10,340
indent expected,

94
00:04:10,340 --> 00:04:12,750
and that's because Python expects there to be some code

95
00:04:12,750 --> 00:04:14,720
after the class declaration,

96
00:04:14,720 --> 00:04:17,620
but we don't wanna provide any just yet.

97
00:04:17,620 --> 00:04:19,940
Now fortunately, there's a very useful command

98
00:04:19,940 --> 00:04:22,680
called pass that doesn't do anything

99
00:04:22,680 --> 00:04:25,430
so I can just type that in there.

100
00:04:27,240 --> 00:04:29,180
So pass doesn't do anything at all,

101
00:04:29,180 --> 00:04:30,560
but unlike a comment,

102
00:04:30,560 --> 00:04:32,950
it doesn't get ignored by the compiler.

103
00:04:32,950 --> 00:04:35,780
So by including it in instruction that does nothing,

104
00:04:35,780 --> 00:04:37,790
we've removed the syntax error

105
00:04:37,790 --> 00:04:41,410
and our code will ultimately be able to run.

106
00:04:41,410 --> 00:04:44,420
Now it may seem strange that an instruction to do nothing

107
00:04:44,420 --> 00:04:45,820
is very useful,

108
00:04:45,820 --> 00:04:49,560
but you'll come across pass in all sorts of places.

109
00:04:49,560 --> 00:04:52,350
Now you may wanna catch an error, an exception,

110
00:04:52,350 --> 00:04:54,990
that we've covered in section 13

111
00:04:54,990 --> 00:04:56,840
to prevent the programme crashing,

112
00:04:56,840 --> 00:04:59,700
but don't wanna do anything if the error happens.

113
00:04:59,700 --> 00:05:03,220
For example, if your programme is reading a load of data

114
00:05:03,220 --> 00:05:05,840
that was provided by people completing the survey,

115
00:05:05,840 --> 00:05:07,830
you may have to convert their date of birth

116
00:05:07,830 --> 00:05:09,740
into a valid Python date.

117
00:05:09,740 --> 00:05:12,280
Now some people would rather not give their date of birth,

118
00:05:12,280 --> 00:05:14,460
so that particular field could be blank.

119
00:05:14,460 --> 00:05:15,650
So you could trap the error

120
00:05:15,650 --> 00:05:19,190
when the code tries to convert no input into a date,

121
00:05:19,190 --> 00:05:21,270
but there's no action that needs to be taken,

122
00:05:21,270 --> 00:05:23,030
you just wanna skip that field

123
00:05:23,030 --> 00:05:27,140
and continue passing or continue processing the data.

124
00:05:27,140 --> 00:05:29,180
So that's a good time to use pass

125
00:05:29,180 --> 00:05:30,510
so that you can catch the error

126
00:05:30,510 --> 00:05:32,950
but continue without doing anything.

127
00:05:32,950 --> 00:05:35,040
So you can find more information on pass

128
00:05:35,040 --> 00:05:36,510
in the documentation.

129
00:05:36,510 --> 00:05:38,090
But rather than give you a link this time,

130
00:05:38,090 --> 00:05:40,620
I'm gonna show you one thing that may be confusing

131
00:05:40,620 --> 00:05:43,090
when you search for Python documentation

132
00:05:43,090 --> 00:05:45,190
using a search engine.

133
00:05:45,190 --> 00:05:47,020
So if I open a browser

134
00:05:48,500 --> 00:05:51,410
and do a search for pass in Python,

135
00:05:54,880 --> 00:05:56,660
we've got stack overflow tutorials,

136
00:05:56,660 --> 00:05:58,700
important stack flow, et cetera,

137
00:05:58,700 --> 00:06:00,480
but I suggest always starting with links

138
00:06:00,480 --> 00:06:02,800
to the Python documentation.

139
00:06:02,800 --> 00:06:04,870
But with that said, you'll often find references

140
00:06:04,870 --> 00:06:08,100
when you're searching for general Python information

141
00:06:08,100 --> 00:06:10,200
to links that are Python 2.7,

142
00:06:10,200 --> 00:06:13,000
as is the case in this fourth link here,

143
00:06:13,000 --> 00:06:16,020
and obviously we want the Python 3 documentation.

144
00:06:16,020 --> 00:06:19,190
Now the Python 2 documentation tends to be returned

145
00:06:19,190 --> 00:06:21,550
because of the way the document is organised

146
00:06:21,550 --> 00:06:24,170
so click the link anyway

147
00:06:24,170 --> 00:06:27,230
and ignore the fact that it's for Python 2.

148
00:06:27,230 --> 00:06:28,380
Then not surprisingly,

149
00:06:28,380 --> 00:06:31,150
we get the documentation coming up for Python 2,

150
00:06:31,150 --> 00:06:32,730
2.7 in this case,

151
00:06:32,730 --> 00:06:35,720
but as you can see up in the top left is a dropdown

152
00:06:35,720 --> 00:06:37,860
that lets you choose which version of Python

153
00:06:37,860 --> 00:06:39,180
you're interested in.

154
00:06:39,180 --> 00:06:41,950
So you can choose 3.5 from there

155
00:06:41,950 --> 00:06:44,200
and I recommend you do that

156
00:06:45,230 --> 00:06:46,860
to make sure the information you're getting

157
00:06:46,860 --> 00:06:48,560
is for the right version.

158
00:06:48,560 --> 00:06:49,810
So don't rule out those links

159
00:06:49,810 --> 00:06:52,230
because they mention the earlier version of Python.

160
00:06:52,230 --> 00:06:54,750
Once you get to the docs.python.org site

161
00:06:54,750 --> 00:06:56,610
like where we are now,

162
00:06:56,610 --> 00:06:58,710
you can still choose the version of Python

163
00:06:58,710 --> 00:07:00,440
that you're interested in.

164
00:07:00,440 --> 00:07:02,660
Now Python 3.6 haven't been released

165
00:07:02,660 --> 00:07:04,560
at the time of recording this video,

166
00:07:04,560 --> 00:07:07,160
but what it is you'll be able to get the documentation

167
00:07:07,160 --> 00:07:09,540
for that version from here as well.

168
00:07:09,540 --> 00:07:12,830
The same for Python 3.7 which is still in development.

169
00:07:12,830 --> 00:07:15,640
Okay, back to our main programme,

170
00:07:15,640 --> 00:07:17,360
so I'm gonna go back to main

171
00:07:17,360 --> 00:07:21,980
and what we need to do now is import enemy and troll

172
00:07:21,980 --> 00:07:24,940
without having to qualify them with a module name

173
00:07:24,940 --> 00:07:27,190
so that we don't have to write enemy.troll

174
00:07:27,190 --> 00:07:29,440
whenever we wanna create a new troll instance.

175
00:07:29,440 --> 00:07:31,870
So I can put from enemy import Enemy

176
00:07:31,870 --> 00:07:34,330
and we can just put a comma

177
00:07:34,330 --> 00:07:35,160
Troll

178
00:07:36,160 --> 00:07:38,150
and we're getting that warning because it's unused

179
00:07:38,150 --> 00:07:41,020
but that we're going to change shortly.

180
00:07:41,020 --> 00:07:43,070
Now we don't really wanna use the enemy class anymore,

181
00:07:43,070 --> 00:07:44,350
but before I delete it,

182
00:07:44,350 --> 00:07:47,130
I just wanted to show you how to import several classes

183
00:07:47,130 --> 00:07:48,850
from the same module.

184
00:07:48,850 --> 00:07:52,370
All right, so let's go down here on line 15

185
00:07:52,370 --> 00:07:55,870
and we'll put ugly_troll is equal to Troll

186
00:07:59,090 --> 00:08:03,260
then we gotta do print Ugly troll replacement field

187
00:08:06,600 --> 00:08:08,190
.format ugly_troll.

188
00:08:11,370 --> 00:08:12,790
Okay, we run that

189
00:08:14,880 --> 00:08:15,760
and we can see down at the bottom,

190
00:08:15,760 --> 00:08:17,440
the ugly troll printout

191
00:08:17,440 --> 00:08:20,040
or the ugly troll information is being displayed,

192
00:08:20,040 --> 00:08:21,680
but it's not too good at the moment though.

193
00:08:21,680 --> 00:08:24,090
The name is still enemy as you can see

194
00:08:24,090 --> 00:08:25,910
in the output down at the bottom

195
00:08:25,910 --> 00:08:27,760
and the troll has got no hit points

196
00:08:27,760 --> 00:08:29,040
so it's probably not gonna be

197
00:08:29,040 --> 00:08:31,340
a very challenging enemy to fight.

198
00:08:31,340 --> 00:08:33,169
Now we didn't add an init method

199
00:08:33,169 --> 00:08:34,919
so creating a troll like this

200
00:08:34,919 --> 00:08:38,320
uses the default values for the enemy class.

201
00:08:38,320 --> 00:08:41,510
Now the enemy class init method takes three arguments

202
00:08:41,510 --> 00:08:43,320
so we can create another troll

203
00:08:43,320 --> 00:08:46,710
and pass some values to the constructor.

204
00:08:46,710 --> 00:08:49,490
All right, so let's remove the code that created our enemy

205
00:08:49,490 --> 00:08:51,430
so we're just working with trolls now.

206
00:08:51,430 --> 00:08:54,860
So I'm gonna delete all this right up to there

207
00:08:54,860 --> 00:08:57,620
because we don't need the enemy anymore

208
00:08:57,620 --> 00:09:01,360
and then we'll add another troll as well

209
00:09:01,360 --> 00:09:05,530
so we'll put another_troll is equal to Troll Ug, 18, 1

210
00:09:11,720 --> 00:09:15,310
and we'll do a printout print another_troll

211
00:09:17,020 --> 00:09:21,190
replacement field so no output .format and another_troll.

212
00:09:25,630 --> 00:09:29,320
So this time I've created another troll with the name Ug

213
00:09:29,320 --> 00:09:32,750
that takes or has 18 hit points.

214
00:09:32,750 --> 00:09:36,280
All right, so let's create another troll, Ug's brother,

215
00:09:36,280 --> 00:09:40,450
he's called Urg so we'll call it brother equals Troll,

216
00:09:45,190 --> 00:09:48,040
we'll call him Urg and this guy's a bit of a brute

217
00:09:48,040 --> 00:09:49,750
even by troll standards

218
00:09:49,750 --> 00:09:51,980
and he can take 23 hit points and damage

219
00:09:51,980 --> 00:09:55,480
so let's set that to 23 and print brother.

220
00:09:58,420 --> 00:10:00,590
Now if you're used to overloaded constructors

221
00:10:00,590 --> 00:10:02,500
in languages such as Java,

222
00:10:02,500 --> 00:10:04,260
then you'd probably be quite happy

223
00:10:04,260 --> 00:10:05,630
with what's going on here,

224
00:10:05,630 --> 00:10:08,880
even if you can't quite work out how Python is doing it.

225
00:10:08,880 --> 00:10:10,300
But if you've never used another language,

226
00:10:10,300 --> 00:10:12,970
then this might be a bit confusing what I've just done.

227
00:10:12,970 --> 00:10:15,380
So when you overload a method

228
00:10:15,380 --> 00:10:17,040
in other programming languages,

229
00:10:17,040 --> 00:10:19,840
you provide a method with exactly the same name

230
00:10:19,840 --> 00:10:22,300
but taking different arguments.

231
00:10:22,300 --> 00:10:26,280
So the ugly troll constructor on line three

232
00:10:26,280 --> 00:10:28,100
doesn't take any arguments

233
00:10:28,100 --> 00:10:31,670
and another_troll constructor on line six

234
00:10:31,670 --> 00:10:33,800
takes or gets three arguments

235
00:10:33,800 --> 00:10:36,810
and his brother Urg on line nine

236
00:10:36,810 --> 00:10:38,700
and he has two arguments.

237
00:10:38,700 --> 00:10:41,420
Now in Java, you'd need to write three constructors,

238
00:10:41,420 --> 00:10:43,350
one for each case.

239
00:10:43,350 --> 00:10:45,350
However, Python doesn't have the concept

240
00:10:45,350 --> 00:10:47,320
of overloaded methods.

241
00:10:47,320 --> 00:10:48,630
Now if you try,

242
00:10:48,630 --> 00:10:50,890
the last method that you defined in the code

243
00:10:50,890 --> 00:10:53,430
will be the only one that exists.

244
00:10:53,430 --> 00:10:56,520
Now if you haven't used another object oriented language,

245
00:10:56,520 --> 00:10:58,270
then don't worry about that last bit,

246
00:10:58,270 --> 00:11:00,090
overloaded methods and so forth,

247
00:11:00,090 --> 00:11:01,930
because Python doesn't have them

248
00:11:01,930 --> 00:11:04,380
and I'm gonna be explaining how all this is working

249
00:11:04,380 --> 00:11:05,290
in a minute.

250
00:11:05,290 --> 00:11:08,280
But for those who have come from other languages

251
00:11:08,280 --> 00:11:11,340
and thinking this looks like method overloading,

252
00:11:11,340 --> 00:11:12,680
it actually isn't,

253
00:11:12,680 --> 00:11:15,900
but it is how you achieve the same thing in Python.

254
00:11:15,900 --> 00:11:18,820
All we've done here is use optional name to parameters

255
00:11:18,820 --> 00:11:21,480
in the enemy class init method.

256
00:11:21,480 --> 00:11:23,830
And it's really now different from using the print method

257
00:11:23,830 --> 00:11:27,080
to print things out because on line 10,

258
00:11:27,080 --> 00:11:28,680
we print brother

259
00:11:28,680 --> 00:11:31,480
and that's the only argument we provided to the function.

260
00:11:31,480 --> 00:11:33,500
Printout does take other arguments

261
00:11:33,500 --> 00:11:36,780
so you could specify that there's no end of line character

262
00:11:36,780 --> 00:11:38,000
for example.

263
00:11:38,000 --> 00:11:40,010
So I'm gonna come along here.

264
00:11:40,010 --> 00:11:43,980
Actually, let's do it on line seven, so another_troll,

265
00:11:43,980 --> 00:11:45,070
and you save this before encoding

266
00:11:45,070 --> 00:11:48,580
and equals and two double quotes,

267
00:11:48,580 --> 00:11:50,350
an empty string in other words,

268
00:11:50,350 --> 00:11:51,940
so when we do that,

269
00:11:53,570 --> 00:11:57,100
we find the another_troll Urg and his brother argument

270
00:11:57,100 --> 00:11:59,940
and his brother Urg are now printed on the same line

271
00:11:59,940 --> 00:12:01,900
because we've removed the end of line

272
00:12:01,900 --> 00:12:04,440
or replaced that with an empty string.

273
00:12:04,440 --> 00:12:06,300
So this is not the best example

274
00:12:06,300 --> 00:12:08,710
because we have to specify the name end.

275
00:12:08,710 --> 00:12:10,550
That's because the print function

276
00:12:10,550 --> 00:12:12,900
can take any number of strings to print

277
00:12:12,900 --> 00:12:14,080
so just adding another one

278
00:12:14,080 --> 00:12:16,340
to the list of arguments wouldn't work.

279
00:12:16,340 --> 00:12:18,820
But for methods that have a fixed number of arguments,

280
00:12:18,820 --> 00:12:21,750
you can provide them without using their names

281
00:12:21,750 --> 00:12:24,420
as long as you keep them in the same position

282
00:12:24,420 --> 00:12:27,010
that they were specified originally.

283
00:12:27,010 --> 00:12:30,510
So when we don't specify any arguments on line three,

284
00:12:30,510 --> 00:12:32,190
the default values that we specified

285
00:12:32,190 --> 00:12:34,860
in enemy's init method are used.

286
00:12:36,330 --> 00:12:39,730
And you can see we've got name equals enemy,

287
00:12:39,730 --> 00:12:42,460
hit points equal zero, lives equals one.

288
00:12:42,460 --> 00:12:45,200
So obviously the default values

289
00:12:45,200 --> 00:12:49,680
are the ones that are after the equal sign on each.

290
00:12:49,680 --> 00:12:51,060
We're going back here now to main.

291
00:12:51,060 --> 00:12:54,280
On line six, all the values were specified.

292
00:12:54,280 --> 00:12:55,730
And then on line nine,

293
00:12:55,730 --> 00:12:58,830
only the two arguments were specified.

294
00:12:58,830 --> 00:13:03,210
So name in this case on line nine gets the value of Urg

295
00:13:03,210 --> 00:13:05,530
and hit points gets the value of 23

296
00:13:05,530 --> 00:13:07,610
then the lives were defaulted to one

297
00:13:07,610 --> 00:13:08,900
because of the way we have defined this

298
00:13:08,900 --> 00:13:12,720
as the default value for the lives attribute.

299
00:13:12,720 --> 00:13:14,140
So once again,

300
00:13:14,140 --> 00:13:17,520
if you are used to languages such as Java or C++,

301
00:13:17,520 --> 00:13:21,690
you can't actually overload functions and methods in Python,

302
00:13:21,690 --> 00:13:23,900
but you can generally get the same effect

303
00:13:23,900 --> 00:13:27,120
by using named parameters with default values.

304
00:13:27,120 --> 00:13:29,270
All right, so I'm gonna stop the video here.

305
00:13:29,270 --> 00:13:30,100
In the next video,

306
00:13:30,100 --> 00:13:32,000
we're going to look at making our troll class

307
00:13:32,000 --> 00:13:34,440
a little bit more useful but at the moment,

308
00:13:34,440 --> 00:13:36,550
we could do exactly the same thing

309
00:13:36,550 --> 00:13:38,850
by using the enemy class rather than a troll.

310
00:13:38,850 --> 00:13:39,680
So in other words,

311
00:13:39,680 --> 00:13:43,650
we could come back here and change that to enemy.

312
00:13:43,650 --> 00:13:45,320
And if you run that,

313
00:13:46,740 --> 00:13:48,740
we get exactly the same result.

314
00:13:48,740 --> 00:13:50,810
So although troll is a subclass of enemy,

315
00:13:50,810 --> 00:13:53,140
at the moment it's not a very useful one.

316
00:13:53,140 --> 00:13:55,230
Now in the next video, we'll make some changes

317
00:13:55,230 --> 00:13:57,710
and see the advantages of creating classes

318
00:13:57,710 --> 00:13:59,990
that inherit from another class.

319
00:13:59,990 --> 00:14:00,930
But just before I do that,

320
00:14:00,930 --> 00:14:05,430
I'm gonna remove this and equals part on line seven.

321
00:14:05,430 --> 00:14:08,200
Okay, so I'll see you in the next video.

