All right so let's start. So maybe we can start with the 1
spell because I think that's the easiest, okay? We know that 2
it's an abstract class. You just add a name and an abstract 3
function it seems. So let's start with that. Let's create a 4
spell class. It is going to be abstract. And so inside we said 5
that we have a name that is probably a string and we should 6
expose this name so we'll have get name and we're going to 7
return this underscore name. So we're going to need a cast 8
function as well. So I'm going to create an abstract cast 9
like this and void so remember here the syntax is a bit 10
different than from in an interface okay in an interface 11
you would do something like this but this is not going to 12
work in an abstract class okay so the syntax is a bit 13
different like this and finally we need a constructor to fill 14
the name so we're going to create a constructor name 15
string and we're going to fill the name with the name that we 16
have here and technically yes we shouldn't have any error 17
okay we're good with the spell okay so we're good with that so 18
spell is done maybe we can continue on easy things like the 19
fire spell and the fire spell name the frost spell and the 20
frost spell name so first let's start with the enums okay 21
because we know that we have to create enums for the names so 22
I'm going to create interface that is going to be fire spell 23
name not sorry not an interface anonymous and this enum I will 24
have fire bolt and I'm going to rename and I'm going to set the 25
content to fire bolt like this so I can display the name 26
correctly. I will have firewall and I will have big bang and we 27
can do the same thing but for the frost spell name 28
So we have the frost bolt. And we have the blizzard. 29
Okay. So we are good. We are with the spell name and we are good 30
with the frost spell name now let's work on the fire spell 31
and the frost spell so let's start with the fire spell so 32
we'll add a class fire spell that should extends spell since 33
it extends spell we have to implement the cast method and 34
that's fine we know what to do we have to display boom you are 35
burning the enemy so we're going to Take this console. 36
log 37
but first I think I have to display the name of the spell 38
so I'm going to display this. name here then boom you are 39
burning the enemy it took 20 damage but twenty damage is 40
burning damage okay and it's a value that cannot be modified 41
so it has to be read only so I'm going to create a read only 42
burning damage equal to 20 and that's what I'm going to use 43
here okay so I'm going to use back quotes and then display 44
here the burning damage so pretty easy and we can do 45
something quite similar for the frost spell frost spell that 46
extend the spell as well it doesn't have a burning damage 47
but as a slowing rate that is zero. five and I think the 48
sentence is a bit different it's your freezing okay so I'm 49
going to display that and here it's going to be the this dot 50
slowing rate and we're good for the frost spell and for the 51
fire spell. Cool, so let's check all of that. So yes, it 52
inerate, it has a slowing and it display the correct thing and 53
we forgot that it's supposed to be initialized with a name 54
only, meaning that we have to create a constructor. So let's 55
do that. 56
So for each one let's create a constructor and here we're 57
going to receive a name that should be a fire spell name. 58
And we're going to set the name so here in spell as you can see 59
that's when we set the name so we have to call this 60
constructor to fill the name here to call the constructor of 61
the parent we have to call super and then send the value 62
and here it's a name so let's just do that and let's repeat 63
the same thing but in the frost spell class and here it's going 64
to be a frost spell name and now we good. Okay, cool. So now 65
technically, we're good with the fire spell and we're good 66
with the frost spell. Well, we did we did a lot. Now the 67
wizard. The wizard. Uh maybe we're going to do the wizard in 68
the next one, okay? Because this video is going to be a bit 69
too long. So let's do that in the next one.