Again I referred to the name of the text.
Your class takes the bird.
And then I put an assignment operator here and then I cast this object to a text you object find view
by ID card that Id dot X the bird and then I put a semi-colon at the end of my statement.
OK so now I can interact with these components in the screen here.
OK.
I just need to refer to the name of that the animal object the animal that said text animal on that.
And then I referred to the name of the string Meffert that I override it inside the Animal class.
OK so now let's actually run our project and see what happens.
OK.
As you can see here this is the value that is outputted here.
OK name Tiger Carlier aren't.
And these are the two values for the speed and power.
So as you can see here we cannot understand.
What are these values relate to.
OK.
So let's actually go back inside the animate Animal class and as you can see here here I can actually
put others tokens in order to specify what are these amount of speed instance valuable and this amount
of power instance variable relate to.
OK.
So let's actually put another percent here.
Person as colon and let's actually put another percent here.
OK.
So now we need to actually put other arguments here in order to actually relate those arguments to these
tokens here.
OK.
So after this color instance variable i just need to put in two double coats and that inside double
quotes.
I can just type in speed.
OK.
And then I put in a comma here and after this amount of spit instance variable i just need to put into
double quotes and then inserted double quotes.
I just need to type in power.
So as you can see here now this string literal here is related to these are actually at auction here.
OK.
Percent.
Yes.
OK.
We specified that we are going to have an argument of type.
Strange.
OK.
And these are is here is actually related to this string lead role here.
OK.
So let's actually put a comma here.
As you can see there is an error here.
We need to actually put a comma here in order to actually separate these arguments here.
And if I don't my project again let's see what happens.
Now it's going to take quite some time in order to actually run our project as you can see.
This is the value that is out with that Hiroki named Tiger color aren't speed 60 power 60.
OK.
So as you can see here with just two line of codes we did manage.
We did manage to output these values to the screen here.
OK.
So that's the power of inheritance inside the animal class.
Let's actually double click on this tab here.
I actually override this method in order to actually output a string value to the screen.
OK.
And here in say the main activity class here as you can see I created an object from the friendly animal
class and with only one line of code I did manage to actually output this value to the screen here.
OK.
Next the animal that takes animal won.
That was three.
OK.
So hopefully that makes sense.
So now let's actually go on and work on these cat class here.
OK.
Now inside the cat class I want to actually create some instance variables.
OK.
So remember that only specific types of animals are inside the cat family.
Like actually Tigers lion leopard and other animals.
OK.
So first I want to actually create some instance variables private.
OK fine.
So this idea is going to be a constant stream data type of my variable is a string and the name of my
variable is name.
Ok private fine on a strange color.
Private's ain't amount of speed.
Ok private
ain't amount of power
OK.
So as you can see here I am actually duplicating some codes that are inside to inside the Animal class
here into this chat class here.
OK.
So and there is a reason for that and I want to actually show you if we don't actually use the inheritance
what are the problems that we may encounter in our projects.
OK.
So here I am actually duplicating some codes that are inside the animal class.
OK so now let's actually create some instance variables for these acads class ok.
Private fine on
NKT number of Lex
ocelli private boolean can hunt other animals.
OK.
And boolean variables can only hold a true value or a false value.
OK so the name of my variable is Chantant other animals.
So now let's actually create a constructor in order to initialize these instance variables here.
OK so first in order to create a constructor I need to actually specify the access modifier of my constructor
first public.
And then I need to give a name to my constructor so the name of my constructor must be the same as the
name of this cat class.
OK.
So public chats and then I put in a Around two decades after my constructor name.
And then I actually opened and closed my constructor by using these curly braces.
OK.
So inside the Prentice's I want to actually specify that my constructor is going to accept arguments.
OK so the first sort the data type of the first argument is a three.
The name of my argument is name comma as strange caller comma int amount of speed.
Comma in and out of power comma.
Ain't number of legs.
Come on Boullion can hunt other animals OK.
Inside the constructor.
Let's actually initialize these instance variables.
So inside the constructor in order to refer to this named instance variable I just type in here this
dot name assignment operator name.
OK.
These dot color assignments operator color.
OK.
So as you can see here this name here refers to this named instance variable and this name here refers
to this name argument here.
Ok to this argument and this color refers to this color instance variable here and this color refers
to this argument here.
OK.
So that's why we actually put this key vote here.
Does that color this refers to this class.
Ok so at this dot amount of speed assignment operator amount of speed does that amount of power assignment
operator amount of power.
OK.
Again these that number of legs.
Assignment operator number of legs these that can hunt other animals assignments operator can hunt other
animals.
OK.
So as you can see here I initialized this instance variables here.
OK.
So now you might actually create some getters and setters for actualities instance variables.
OK.
So now you want to actually show you a trick in order to generate the get here and setters automatically
OK.
So actually our Right-Click outside of this constructor right click here and then go to generate click
and generate and then click on get her and set her on.
As you can see here we've got this instance variables here.
OK this name instance variable color instance variable amount of speed instance variable amount of power
instance variable number of legs instance variable and this can't can hunt other animals instance variable
which is of type float.
OK.
So if I actually select all of these instance variables here by holding on command key on my keyboard
and then clicking on these for instance variables.
If you are using a Windows machine you need to actually hold the control key on your keyboard and then
select all of these instance variables OK and then click on OK.
So as you can see here are the Android studio automatically generated getters and setters for my instance
variables.
OK.