But as you know a lion is actually an animal.
OK.
So I can actually inherit all of the features and behaviors that are actually inside of the Animal class
so extends animal here.
And these are the instance variables that are specific only to display in class privates Boullion can
fight too.
OK.
And here I created.
I actually did declare an instance variable private int fighting power and as you can see here I didn't
instantiate this instance variable here.
OK.
Now let's actually create a constructor for this like in class here.
OK so now I'm going to have truly pasting this constructive and then I'm going to explain to you what's
going on here.
So as you can see here this is the constructor that I actually pasted here.
OK.
And here you can see that as you can see the Axis modifier of this kind of structure is public.
The name of this constructor must be the same as the name of this class.
OK.
And here as you can see this constructor actually accepts some arguments.
Ok the first argument is of types 3 an animal name.
The second argument is of type against string.
Animal color into power in speed.
And here as you can see Boullion can fight.
OK.
And it fighting power.
So here because we are actually inheriting all of the features and behaviors that are inside of this
animal class we need to call it actually the constructor of the superclass or Keaveney to actually initialize
the constructor of the superclass.
So as you can see here.
Super.
OK.
See this super actually refers to the superclass animal.
OK here you want to initialize the constructor of the superclass.
OK.
So super animal name.
OK.
So this animal name as you can see animal inside of the Animal class we have this constructor here.
OK.
So this constructor as you can see the first argument that this animal constructed actually accepts
is of type strange animal name.
OK.
So inside of this lion class I am actually assigning.
That's why you here to that to that instance variable that is inside this animal here inside of these
Animal class.
OK.
So like an animal named animal color as you can see here power and speed here.
And these are these two instance variables as you can see here these can fight in Cincinnati.
And these fighting power is actually these are actually specific only through this low class sort of
chant fight and fight in power here as you can see.
First of all I created an if statement here.
OK.
If the value of this fighting power.
OK if the value of the swanking power arguments is less than or equal to number 0 then of throw on you
actually exception for new argument exception the value of the argument the power must be greater than
number zero as you can see here.
OK.
And here as you can see I am instantiating these actually these instance variables these that can fight
assignment operator can fight the start fighting power assignments operator fighting and power.
OK so now let's actually create some are getters and setters for these instance variables.
So here inside of this class I just would like to click here and then you can generate and then click
can get here and sit here and here choose these two instance variables and then click on OK here.
So as you can see here these are my instant actually these are my getters and setters for these two
instance variables as you can see here up is can fight said can fight.
So I don't like this name here is can't fight.
So I just did it this is here and I can just type in jets.
Gays can fight so it can fight get fighting power and set fighting power.
OK.
Let's actually up to calculate Meffert as you can see we have another addendum if you calculate the
overall power of animal method here.
So because this lion class actually inherits all of the features and behaviors that are actually inside
of this animal class I can override that method here so I can just I can calculate.
And as you can see I can refer to the name of that method here and that if I press enter here on my
keyboard now you can see this left here.
It calculates the overall power of any man.
And here as you can see it says Return superior that calculate the overall power of any man.
So again just put a A-plus operator here and then I'm going to actually putting the fighting power here.
In power as you can see here this superhero actually refers to the name of the superclass animal.
This calculates the overall power of animal if it actually is going to execute this line of code here
gives animal power multiplied by the value of the animal speed.
And then I am actually adding the value of this fighting power to that value.
OK.
And then I am returning that value to the call to the call of the spec for it.
OK so now let's actually override the two string method that is inside of the superclass of this in
class.
So I can just say two three.
And as you can see here it says is written superdad to strange here.
OK.
So let's actually delete this line of code here and here it's actually type router.
OK strange that format an insert of the Prentice's of this format.
And when I tried putting a piece of code here and then I'm going to explain to you what's going on here.
So the double quotes as you can see the percept is OK.
So this person is actually refers to this argument Super 8 that was three.
So as you know super refers to the name of the superclass animal.
And this truthtelling Meffert actually refers to this implementation that is actually the inside of
this two string Meffert that is inside of this superclass animal.
OK.
So it's going to execute these lines of code here in that format.
OK.
And then it's going to return the value of the animal name animal color animal power at animal speed.
OK.
Inside of the lion close as you can see here that's actually putting a semicolon here at the end of
our statement.
So that now the arrow is gone.
And here we have a new line character percent and and I have a person and another person is here as
you can see.
So this position here is for this chan are like a fight.
OK this is strange.
Colin and I have asked this person to be here.
So this person's appeal is for this catfight valuable.
OK.
So as you can see here this is not the best way to write our coats here.
I should actually be fair to the name of the Get can fight method here in order to return the value
of these are.
Chan fight.
Ready.
OK.
So this person is what this gets.
Can't fight left here and another nearby character person in and behalf of another person is here.
So he's talking in his 40s value the fighting power of our lion ears.
OK.
Person.
So this person is for this instance variable fighting power.
So here again this is not the best way in order to write Ancoats here.
I should just refer to the name of the kids fighting power.
OK.
Kids fighting power and here is going to return the value of these fighting power instance variable
OK.
So now let's actually go back and say this main activity that Javal fight here and here inside that
this uncreate Somerford that's actually putting some more lines of code here.
So now inside of this uncreate Meffert Let's actually create some objects from the Take take a class.
So as you can see here I actually created Freep objects from these text class.
OK.
The first object is to the animal.
And here you referred to the name of this idea or that idea that the animal and the second object is
the lion.
And here I referred to the name of this ID or that idea that takes the lion and does the first argument
as you can see the first object is the polymorphism.
And here I referred to the name of this ITTL the polymorphism here.
OK let's actually put some more lines of code here.
So here I want to actually create two objects one object from this animal class and another object from
the lion class.
OK.
So as you can see here these are my two objects anemone and the name of this object is animal.
And here I am actually instantiating this object here.
And as you can see I am passing some values to the constructor of this animal class the name of this
animal is where the color of this animal is black.
And here as you can see I assigned an invalid number to these animal power.
And again I actually assigned an invalid numbers to this animal species.
OK.
And then here I actually created an object from the lion class and the name of this object is a lion.
And then I actually assigned somebody used to the constructor of this lion class as you can see here.
And the name of this lion is my lion the color of this lion is yellow.
And here as you can see for the animal power I have actually assigned an invalid number and he had for
the animal split again I assigned an invalid number.
Number negative one and he had this value as you can see inside of this lion class this value here it
can fight boolean variable.
So here inside of this our main activity that I will find here you can see that I assigned a value of
true for the can fight instance variable of this object and this number here one hundred and seventy
is for these fighting power here.
OK.
So inside of this main activity that over here I created these two objects.