1
00:00:00,189 --> 00:00:02,640
(light music)

2
00:00:02,640 --> 00:00:05,315
(keys clicking)

3
00:00:05,315 --> 00:00:07,256
In this video, we're gonna start talking about

4
00:00:07,256 --> 00:00:09,669
an object-oriented term called inheritance.

5
00:00:09,669 --> 00:00:10,793
But before I do that,

6
00:00:10,793 --> 00:00:13,455
I want to show you how to the fix the problem

7
00:00:13,455 --> 00:00:17,661
whereby sometimes Android Studio won't compile Kotlin code,

8
00:00:17,661 --> 00:00:19,361
or at least that happened for me,

9
00:00:19,361 --> 00:00:21,113
and I actually found the solution to the problem.

10
00:00:21,113 --> 00:00:22,523
So, just in case you're getting this problem,

11
00:00:22,523 --> 00:00:23,960
this is how to fix it.

12
00:00:23,960 --> 00:00:27,982
Now the problem is, that when I type some code, println,

13
00:00:27,982 --> 00:00:31,815
this is a test, and I've got to run that code,

14
00:00:33,442 --> 00:00:35,006
you can see that println, this is a test,

15
00:00:35,006 --> 00:00:36,713
the code hasn't been executed.

16
00:00:36,713 --> 00:00:38,808
And in fact, what I need to do to get it to work

17
00:00:38,808 --> 00:00:40,391
is make the module,

18
00:00:42,060 --> 00:00:44,020
run it again, and then it'll work.

19
00:00:44,020 --> 00:00:45,154
You can see we're now getting,

20
00:00:45,154 --> 00:00:47,246
this is a test, outputted on the screen.

21
00:00:47,246 --> 00:00:48,588
So the problem's got to do

22
00:00:48,588 --> 00:00:50,578
with the actual build process.

23
00:00:50,578 --> 00:00:52,574
So, you're gonna come up here,

24
00:00:52,574 --> 00:00:53,594
and click on and select,

25
00:00:53,594 --> 00:00:55,855
Edit Configurations.

26
00:00:55,855 --> 00:00:56,850
And the issue is,

27
00:00:56,850 --> 00:00:58,686
that for some reason

28
00:00:58,686 --> 00:01:00,683
this has been set to be just Building.

29
00:01:00,683 --> 00:01:03,206
So we need to actually get it to run the gradle task

30
00:01:03,206 --> 00:01:05,844
to compile the code and then run it.

31
00:01:05,844 --> 00:01:06,776
And that's what's happening

32
00:01:06,776 --> 00:01:08,623
is that's not being executed.

33
00:01:08,623 --> 00:01:11,386
So the fix to this is to select Build,

34
00:01:11,386 --> 00:01:13,178
delete it, then Add.

35
00:01:13,178 --> 00:01:16,269
Your gonna select, Run gradle task.

36
00:01:16,269 --> 00:01:17,988
Then we choose the gradle project,

37
00:01:17,988 --> 00:01:20,547
in this case it'll be the Kotlin Tutorial.

38
00:01:20,547 --> 00:01:22,417
And for tasks, we need to type in

39
00:01:22,417 --> 00:01:23,518
clean build.

40
00:01:23,518 --> 00:01:26,518
(Keyboard clicking)

41
00:01:27,538 --> 00:01:28,729
Click on OK.

42
00:01:28,729 --> 00:01:30,447
So if you already have something that looks very similar

43
00:01:30,447 --> 00:01:32,469
to that you won't need to make this change.

44
00:01:32,469 --> 00:01:34,227
But once we do that,

45
00:01:34,227 --> 00:01:36,215
when we run it

46
00:01:36,215 --> 00:01:38,259
you can see it's now compiling.

47
00:01:38,259 --> 00:01:39,966
And we got the code showing there,

48
00:01:39,966 --> 00:01:40,799
which is fine.

49
00:01:40,799 --> 00:01:43,615
But if I delete this now,

50
00:01:43,615 --> 00:01:44,448
and run this,

51
00:01:44,448 --> 00:01:46,266
we see that the code gets updated automatically

52
00:01:46,266 --> 00:01:48,096
and starts working again.

53
00:01:48,096 --> 00:01:49,008
So it been updated.

54
00:01:49,008 --> 00:01:50,375
So if you did get a problem like that,

55
00:01:50,375 --> 00:01:52,136
that's how to go about fixing it.

56
00:01:52,136 --> 00:01:53,239
Alright, so let's move on.

57
00:01:53,239 --> 00:01:54,557
As I said, in this video

58
00:01:54,557 --> 00:01:56,980
we're going to talk about an object-oriented term

59
00:01:56,980 --> 00:01:58,841
called inheritance

60
00:01:58,841 --> 00:02:02,404
and specifically how that applies to Kotlin programming.

61
00:02:02,404 --> 00:02:04,349
Now, what I'm going to do is start with a definition

62
00:02:04,349 --> 00:02:06,595
and explanation of what it is,

63
00:02:06,595 --> 00:02:09,109
then we'll move into some coding to show you and example

64
00:02:09,109 --> 00:02:11,210
of, with Kotlin, what inheritance is

65
00:02:11,210 --> 00:02:13,543
and also why it's important.

66
00:02:14,682 --> 00:02:15,771
Alright, so let's talk about a

67
00:02:15,771 --> 00:02:18,587
real world example of inheritance.

68
00:02:18,587 --> 00:02:20,660
So, different types of objects in the real world

69
00:02:20,660 --> 00:02:23,591
can have a certain amount in common with each other.

70
00:02:23,591 --> 00:02:25,461
For example, as you can see on this slide,

71
00:02:25,461 --> 00:02:28,301
a Seagull, a Crow and an Eagle,

72
00:02:28,301 --> 00:02:29,608
well they're all birds,

73
00:02:29,608 --> 00:02:32,279
and so are Ostriches and Penguins.

74
00:02:32,279 --> 00:02:34,974
So, in other words they share the, being a bird, traits

75
00:02:34,974 --> 00:02:36,409
so to speak.

76
00:02:36,409 --> 00:02:38,161
They all have a beak and wings,

77
00:02:38,161 --> 00:02:42,328
things they inherit by virtue of them being birds.

78
00:02:43,346 --> 00:02:44,839
Now, another example,

79
00:02:44,839 --> 00:02:46,555
to get away from the natural world,

80
00:02:46,555 --> 00:02:48,305
could be motor vehicles.

81
00:02:48,305 --> 00:02:51,614
A motor car, a lorry and a digger on a building site,

82
00:02:51,614 --> 00:02:54,545
all share common characteristics.

83
00:02:54,545 --> 00:02:56,041
They all have wheels, for one thing,

84
00:02:56,041 --> 00:03:00,053
and are generally powered by and internal combustion engine.

85
00:03:00,053 --> 00:03:02,535
Now, we could say that all these three different vehicles

86
00:03:02,535 --> 00:03:06,497
are descended from a a basic vehicle class.

87
00:03:06,497 --> 00:03:08,843
Now, the basic class probably doesn't have an engine,

88
00:03:08,843 --> 00:03:11,776
it would be an early hand cart, perhaps.

89
00:03:11,776 --> 00:03:14,554
Our three vehicles extend the basic hand cart,

90
00:03:14,554 --> 00:03:16,697
with the addition of an engine.

91
00:03:16,697 --> 00:03:18,260
Now, we're discussing class inheritance,

92
00:03:18,260 --> 00:03:20,351
and inheritance is easier to see in nature,

93
00:03:20,351 --> 00:03:21,813
but I wanted to point out

94
00:03:21,813 --> 00:03:25,793
that the things humans produce also evolve.

95
00:03:25,793 --> 00:03:28,332
They build on earlier versions, adding some features,

96
00:03:28,332 --> 00:03:31,650
and changing the way other features are implemented.

97
00:03:31,650 --> 00:03:32,729
We now have electric cars,

98
00:03:32,729 --> 00:03:35,542
which share a common ancestry with the earlier petrol

99
00:03:35,542 --> 00:03:38,449
and diesel powered versions.

100
00:03:38,449 --> 00:03:39,519
So, I'm gonna stick with birds

101
00:03:39,519 --> 00:03:41,077
because they're easier to understand

102
00:03:41,077 --> 00:03:44,210
than the workings of modern motor vehicles.

103
00:03:44,210 --> 00:03:46,644
Now, our birds share a lot of traits.

104
00:03:46,644 --> 00:03:48,140
They all have feathers, for example,

105
00:03:48,140 --> 00:03:50,944
that's one of the things that makes them birds.

106
00:03:50,944 --> 00:03:51,777
So what we can do ,

107
00:03:51,777 --> 00:03:55,051
is define a base class that objects are based on,

108
00:03:55,051 --> 00:03:57,873
things that are common for classes that use that.

109
00:03:57,873 --> 00:03:59,015
Then we can allow a class

110
00:03:59,015 --> 00:04:01,904
to define the unique characteristics of itself,

111
00:04:01,904 --> 00:04:04,182
just like in the car example.

112
00:04:04,182 --> 00:04:06,290
So, in other words, we have base class,

113
00:04:06,290 --> 00:04:08,081
then something that inherits from that,

114
00:04:08,081 --> 00:04:11,575
to make it something else, to make it unique.

115
00:04:11,575 --> 00:04:13,538
Now, the base class here is bird,

116
00:04:13,538 --> 00:04:17,704
and from that all the birds inherit a beak and wings.

117
00:04:17,704 --> 00:04:18,750
But each type of bird also has things

118
00:04:18,750 --> 00:04:21,765
that make it different from the others.

119
00:04:21,765 --> 00:04:24,963
So, eagles have incredibly good eyesight, for example.

120
00:04:24,963 --> 00:04:27,637
You may be pleased if you spot a Mcdonalds from 400 metres,

121
00:04:27,637 --> 00:04:31,637
but eagles can see a rabbit from two miles away.

122
00:04:33,915 --> 00:04:36,200
So all our birds inherit some basic properties

123
00:04:36,200 --> 00:04:37,782
from their base class,

124
00:04:37,782 --> 00:04:41,096
which is often referred to as the Super Class.

125
00:04:41,096 --> 00:04:43,024
Now, they also inherit methods,

126
00:04:43,024 --> 00:04:45,204
so all birds can walk and eat.

127
00:04:45,204 --> 00:04:47,645
But the individual bird classes also have their own,

128
00:04:47,645 --> 00:04:50,093
unique properties and methods.

129
00:04:50,093 --> 00:04:53,441
Penguins can swim and ostriches can run, for example.

130
00:04:53,441 --> 00:04:55,073
So these individual bird classes

131
00:04:55,073 --> 00:04:57,674
are referred to as Sub Classes.

132
00:04:57,674 --> 00:05:00,012
So crow is a Sub Class of bird,

133
00:05:00,012 --> 00:05:03,262
which makes bird a Super Class of crow.

134
00:05:04,986 --> 00:05:08,019
Now the idea of sub-classing can be taken further,

135
00:05:08,019 --> 00:05:09,702
so we could add subclasses of bird,

136
00:05:09,702 --> 00:05:13,035
such as flying bird and flightless bird.

137
00:05:15,586 --> 00:05:17,796
Now, eagle is a subclass of flying bird

138
00:05:17,796 --> 00:05:21,477
and ostrich is a subclass of flightless bird.

139
00:05:21,477 --> 00:05:24,009
In our example, eagles, crows and gulls

140
00:05:24,009 --> 00:05:26,237
inherit the ability to fly

141
00:05:26,237 --> 00:05:28,914
from the flying bird superclass.

142
00:05:28,914 --> 00:05:31,557
Ostriches and penguins aren't inheriting anything from their

143
00:05:31,557 --> 00:05:34,073
flightless bird superclass in this example,

144
00:05:34,073 --> 00:05:36,410
but they still inherit their beaks and wings

145
00:05:36,410 --> 00:05:39,139
from the bird superclass.

146
00:05:39,139 --> 00:05:41,034
Now ostriches have a run method

147
00:05:41,034 --> 00:05:42,913
and penguins have a swim method,

148
00:05:42,913 --> 00:05:45,243
so a class can introduce other properties and methods,

149
00:05:45,243 --> 00:05:48,514
in addition to the ones it inherits.

150
00:05:48,514 --> 00:05:50,309
Now a class can have more than one superclass

151
00:05:50,309 --> 00:05:53,059
in a hierarchy like in the slide.

152
00:05:54,829 --> 00:05:56,871
Now flying bird is a subclass of a bird,

153
00:05:56,871 --> 00:05:59,896
and eagle is a subclass of flying bird.

154
00:05:59,896 --> 00:06:01,655
So it's also a subclass of bird

155
00:06:01,655 --> 00:06:03,313
because its immediate superclass,

156
00:06:03,313 --> 00:06:06,756
flying bird, is a subclass of bird.

157
00:06:06,756 --> 00:06:09,349
So just to labour the point one more time,

158
00:06:09,349 --> 00:06:13,026
flying bird is a superclass of the three classes

159
00:06:13,026 --> 00:06:14,576
eagle, crow and gull,

160
00:06:14,576 --> 00:06:17,326
and it's also a subclass of bird.

161
00:06:20,100 --> 00:06:21,425
Now at this point, you might be asking,

162
00:06:21,425 --> 00:06:24,928
why bother to go to this level of complexity?

163
00:06:24,928 --> 00:06:27,351
Well firstly, it allows to write code once,

164
00:06:27,351 --> 00:06:31,134
then for it to be used automatically by other classes.

165
00:06:31,134 --> 00:06:33,326
So if we created an eagle object,

166
00:06:33,326 --> 00:06:36,302
it would automatically get beak and wings properties,

167
00:06:36,302 --> 00:06:38,613
together with any other properties and functions

168
00:06:38,613 --> 00:06:41,044
that we'd created in the bird class

169
00:06:41,044 --> 00:06:44,460
without us having to write any code in the eagle class.

170
00:06:44,460 --> 00:06:46,058
So this really leaves you to define

171
00:06:46,058 --> 00:06:48,338
the unique characteristics of a class,

172
00:06:48,338 --> 00:06:50,156
rather than having to reinvent the wheel

173
00:06:50,156 --> 00:06:53,318
each time you create a new class.

174
00:06:53,318 --> 00:06:55,215
Now you can write that common code once,

175
00:06:55,215 --> 00:06:57,153
put that code in the superclass,

176
00:06:57,153 --> 00:07:00,612
and then any class that extends or inherits from,

177
00:07:00,612 --> 00:07:02,253
they're the same thing effectively,

178
00:07:02,253 --> 00:07:05,861
that superclass is going to get the properties and methods

179
00:07:05,861 --> 00:07:08,321
that are defined in that superclass.

180
00:07:08,321 --> 00:07:09,604
Alright, a lot of theory there,

181
00:07:09,604 --> 00:07:10,980
so let's go write a bit of Kotlin code

182
00:07:10,980 --> 00:07:12,995
so this makes more sense.

183
00:07:12,995 --> 00:07:13,828
What we're going to do is,

184
00:07:13,828 --> 00:07:17,143
by starting out is, I'm going to delete the main function,

185
00:07:17,143 --> 00:07:19,683
so that we've just got the definition.

186
00:07:19,683 --> 00:07:21,044
Like you can see on the screen here

187
00:07:21,044 --> 00:07:22,794
that I'm about to do.

188
00:07:23,943 --> 00:07:25,923
Okay, I'm gonna close the run window for now.

189
00:07:25,923 --> 00:07:28,847
We're obviously going to be using this now for our examples.

190
00:07:28,847 --> 00:07:31,930
Now we're going to create a superclass called, Enemy,

191
00:07:31,930 --> 00:07:34,414
which will be the base class for all the things our players

192
00:07:34,414 --> 00:07:37,798
will have to fight in this fictional game.

193
00:07:37,798 --> 00:07:39,310
So we're going to this what we've done before,

194
00:07:39,310 --> 00:07:40,959
right click the Java folder,

195
00:07:40,959 --> 00:07:44,122
click on New, select Kotlin file/class.

196
00:07:44,122 --> 00:07:45,704
Enter, Enemy as the name.

197
00:07:45,704 --> 00:07:48,696
(keyboard clicking)

198
00:07:48,696 --> 00:07:50,065
Press enter there.

199
00:07:50,065 --> 00:07:51,237
Now we're gonna store the hit points,

200
00:07:51,237 --> 00:07:52,945
and also the number of lives,

201
00:07:52,945 --> 00:07:54,671
so we need to create properties for those

202
00:07:54,671 --> 00:07:56,483
in the primary constructor.

203
00:07:56,483 --> 00:07:58,105
And we should also give the enemy a name.

204
00:07:58,105 --> 00:07:59,697
So let's go ahead and do that.

205
00:07:59,697 --> 00:08:00,724
Class.

206
00:08:00,724 --> 00:08:01,557
Enemy.

207
00:08:02,646 --> 00:08:04,614
Parenthesis, val.

208
00:08:04,614 --> 00:08:05,447
Val.

209
00:08:05,447 --> 00:08:06,280
Name.

210
00:08:08,606 --> 00:08:09,689
Colon stream.

211
00:08:11,482 --> 00:08:13,149
And var, hit points.

212
00:08:14,855 --> 00:08:16,296
Colon, int.

213
00:08:16,296 --> 00:08:18,270
Comma, var, lives

214
00:08:18,270 --> 00:08:21,270
(keyboard clicking)

215
00:08:24,412 --> 00:08:25,245
Okay.

216
00:08:26,223 --> 00:08:28,501
So this is a superclass

217
00:08:28,501 --> 00:08:31,146
and any class that extends this enemy class,

218
00:08:31,146 --> 00:08:32,633
or inherits from this class,

219
00:08:32,633 --> 00:08:33,823
because it means the same thing,

220
00:08:33,823 --> 00:08:38,302
should always have name, hit points, and lives properties,

221
00:08:38,302 --> 00:08:41,039
and in a game scenario that's probably quite reasonable

222
00:08:41,039 --> 00:08:43,222
to assume that it's got those properties.

223
00:08:43,222 --> 00:08:46,759
Now by default, Kotlin classes can't be extended,

224
00:08:46,759 --> 00:08:48,128
and if you're use to Java,

225
00:08:48,128 --> 00:08:51,106
its as though we marked the class final.

226
00:08:51,106 --> 00:08:52,747
Now if you're not use to Java,

227
00:08:52,747 --> 00:08:55,364
what that means is that we can't inherit from enemy

228
00:08:55,364 --> 00:08:57,958
unless we mark it as open.

229
00:08:57,958 --> 00:08:59,464
And as we've declared it here,

230
00:08:59,464 --> 00:09:02,506
enemy can't be used as a superclass.

231
00:09:02,506 --> 00:09:04,571
Now the idea is that code would be more robust

232
00:09:04,571 --> 00:09:07,758
if we don't automatically allow classes to be extend.

233
00:09:07,758 --> 00:09:09,738
If you do want to allow it, as we do here,

234
00:09:09,738 --> 00:09:12,561
you have to explicitly tell Kotlin

235
00:09:12,561 --> 00:09:14,907
that the class can be extended.

236
00:09:14,907 --> 00:09:16,114
Now that's easily done.

237
00:09:16,114 --> 00:09:19,191
We just ad the keyword, open to our declaration of enemies.

238
00:09:19,191 --> 00:09:21,308
So we just come back to the start,

239
00:09:21,308 --> 00:09:22,516
and type open.

240
00:09:22,516 --> 00:09:24,375
And now we can use enemy as a base class

241
00:09:24,375 --> 00:09:26,358
for our real enemy types.

242
00:09:26,358 --> 00:09:28,922
If you're not sure why enemy's declared as, val,

243
00:09:28,922 --> 00:09:31,041
but the other two properties are var

244
00:09:31,041 --> 00:09:34,253
then review the earlier videos in this section.

245
00:09:34,253 --> 00:09:35,384
So I'm gonna create a function here,

246
00:09:35,384 --> 00:09:37,321
we're gonna call it, take damage.

247
00:09:37,321 --> 00:09:38,274
We're gonna call this method

248
00:09:38,274 --> 00:09:40,237
if the enemy is taking some damage.

249
00:09:40,237 --> 00:09:42,293
If it's been hit by something.

250
00:09:42,293 --> 00:09:43,612
So we need to deduct the damage from

251
00:09:43,612 --> 00:09:45,925
the number of hit points in that scenario.

252
00:09:45,925 --> 00:09:47,572
So let's go down and write that function.

253
00:09:47,572 --> 00:09:49,359
So it'd be, fun,

254
00:09:49,359 --> 00:09:50,359
take damage,

255
00:09:52,469 --> 00:09:54,833
and in parenthesis, damage,

256
00:09:54,833 --> 00:09:56,493
colon,

257
00:09:56,493 --> 00:09:58,012
int.

258
00:09:58,012 --> 00:10:00,581
And we'll start by typing, val,

259
00:10:00,581 --> 00:10:01,991
remaining hit points,

260
00:10:01,991 --> 00:10:05,540
(keyboard clicking)

261
00:10:05,540 --> 00:10:07,457
is equal to hit points,

262
00:10:08,355 --> 00:10:09,355
take damage.

263
00:10:10,764 --> 00:10:11,630
Then we're gonna do,

264
00:10:11,630 --> 00:10:15,955
if remaining hit points is greater than zero,

265
00:10:15,955 --> 00:10:17,334
I put up a curly block,

266
00:10:17,334 --> 00:10:18,167
then I'm going to do

267
00:10:18,167 --> 00:10:21,417
hit points equals remaining hit points.

268
00:10:22,597 --> 00:10:23,456
Then we'll print a message,

269
00:10:23,456 --> 00:10:26,550
so println, parenthesis, double quotes,

270
00:10:26,550 --> 00:10:27,550
dollar name,

271
00:10:28,692 --> 00:10:30,275
took dollar damage,

272
00:10:31,539 --> 00:10:32,956
points of damage,

273
00:10:34,828 --> 00:10:35,995
and has dollar

274
00:10:37,168 --> 00:10:38,501
hit points left.

275
00:10:40,492 --> 00:10:41,325
Then on the next line,

276
00:10:41,325 --> 00:10:42,158
else,

277
00:10:43,926 --> 00:10:44,862
and I put a curly block,

278
00:10:44,862 --> 00:10:45,695
lives

279
00:10:47,759 --> 00:10:49,092
minus equal one,

280
00:10:50,112 --> 00:10:52,195
and println, dollar name,

281
00:10:53,159 --> 00:10:54,159
lost a life.

282
00:10:56,378 --> 00:10:58,862
So what we're doing here is we're subtracting

283
00:10:58,862 --> 00:11:02,413
the damage from the number of hit points that enemy has

284
00:11:02,413 --> 00:11:04,361
and checking to see if they've still got any left

285
00:11:04,361 --> 00:11:06,741
after that damage is inflicted.

286
00:11:06,741 --> 00:11:08,805
Now if the number remaining is more than zero,

287
00:11:08,805 --> 00:11:10,606
we update the hit points

288
00:11:10,606 --> 00:11:13,201
and print out a message showing how much damage was taken

289
00:11:13,201 --> 00:11:15,819
and also how many hit points are still left.

290
00:11:15,819 --> 00:11:18,650
But if the hit points have dropped to zero below

291
00:11:18,650 --> 00:11:20,665
then we take off a life instead.

292
00:11:20,665 --> 00:11:22,968
Now I don't think we've seen this form of assignment yet,

293
00:11:22,968 --> 00:11:26,028
lives minus equals one, as you can see on line 13.

294
00:11:26,028 --> 00:11:28,278
That's just a shorthand way

295
00:11:30,015 --> 00:11:30,848
of writing,

296
00:11:30,848 --> 00:11:33,751
lives equals lives take one.

297
00:11:33,751 --> 00:11:35,655
So this form's called augmented assignment

298
00:11:35,655 --> 00:11:38,407
and you can use the short hand

299
00:11:38,407 --> 00:11:40,415
with the five arithmetic operators.

300
00:11:40,415 --> 00:11:42,270
Now what I'm going to do is delete that.

301
00:11:42,270 --> 00:11:45,422
What I will do is I'm going to paste in some code here,

302
00:11:45,422 --> 00:11:47,336
comment it out,

303
00:11:47,336 --> 00:11:48,881
and I'm gonna paste this right down at the end of the file.

304
00:11:48,881 --> 00:11:50,818
I'll show you examples of the operators

305
00:11:50,818 --> 00:11:53,811
and the equivalent shorthand version.

306
00:11:53,811 --> 00:11:55,077
Like so.

307
00:11:55,077 --> 00:11:56,792
And you can see the version on the left,

308
00:11:56,792 --> 00:11:58,454
and the short hand version on the right.

309
00:11:58,454 --> 00:12:00,935
So again, that form's called, augmented assignment.

310
00:12:00,935 --> 00:12:02,388
So those examples show you how you can use

311
00:12:02,388 --> 00:12:04,870
augmented assignment operators when you're modifying

312
00:12:04,870 --> 00:12:06,512
the value of something

313
00:12:06,512 --> 00:12:11,219
and assigning the result back to the original variable.

314
00:12:11,219 --> 00:12:12,700
And I've removed that line of code

315
00:12:12,700 --> 00:12:14,764
so make sure if you're typing along you have done that.

316
00:12:14,764 --> 00:12:16,950
That second line allows you to be taking two lives

317
00:12:16,950 --> 00:12:20,044
away from the enemies, which would be cheating a little bit.

318
00:12:20,044 --> 00:12:22,652
Alright so we should probably at this point check

319
00:12:22,652 --> 00:12:24,538
to see if the enemy's got any lives left,

320
00:12:24,538 --> 00:12:25,958
but we demonstrating concepts here,

321
00:12:25,958 --> 00:12:28,491
not creating a full adventure game.

322
00:12:28,491 --> 00:12:30,166
That could be a useful exercise

323
00:12:30,166 --> 00:12:32,052
for you to try out for yourself though,

324
00:12:32,052 --> 00:12:33,897
to make sure that you've understood what we've covered

325
00:12:33,897 --> 00:12:35,922
in this tutorial.

326
00:12:35,922 --> 00:12:38,360
So we basically got a basic class here,

327
00:12:38,360 --> 00:12:39,634
we're storing the name,

328
00:12:39,634 --> 00:12:41,624
hit points, and lives.

329
00:12:41,624 --> 00:12:43,266
So that's the end of the video here.

330
00:12:43,266 --> 00:12:44,999
In the next video, we start out overwriting

331
00:12:44,999 --> 00:12:47,386
the two string function then we'll move on to creating

332
00:12:47,386 --> 00:12:48,864
some other classes.

333
00:12:48,864 --> 00:12:49,945
So I'll see you in the next video.

