So analysis actually putting some more lines of code here.
So now when I actually create some objects from these classes that they actually created in this project.
OK.
So as you can see here these are the new lines of code that they actually pasted here.
OK.
The first object that I actually created is of type desktop computer and the name of this object is
desktop computer.
And here I put an assignment operator new this that computer.
So here I'm going to instantiate this object by putting this new keyboard and here as you can see I
need to actually passing some arguments to the constructor of this class and the name of.
For example this computer is I-Max.
And as you can see the screen is high quality screen physical keyboard and physical mouse.
And this is the power.
This is the super power.
And this is the Ram.
OK.
And we have a laptop computer.
And as you can see instantiating this laptop computer object.
OK.
And here we need to actually passing some values to the constructor of this laptop computer class match
with prope high quality screen physical keyboard.
And as you can see here and this laptop actually has a physical mouse.
And here as you can see inside of this laptop computer inside of the constructor as you can see I actually
specified that the constructor actually accepts a value of type strips 3.
And the name of this argument is mouse and we can actually create an instance variable for this mouse
here.
Private's OK and strange mouse.
And then here I can actually instantiate this mouse here and here inside of this constructor.
I can't just type in this dot mouse assignment operator mouse.
And now let's actually create a getter and the setter for this mouse instance variable.
So inside of this class click here and then click on generates and then click on getter and setter mouse
and then click on finish.
So as you can see here we have a getter and setter for this mouse instance variable and inside of this
and inside of these two string Meffert they can actually putting a person is here.
OK in person yes.
And now after this get touchpad here I can just put in a come up here and that I put into double coats
and I can just typing mouse OK karma gets mouse OK.
So this person as here is for this string value and this person is for this gets mouse he had as you
can see here.
OK this is the method that returns the value of this mouse instance variable.
So I forgot to actually create an instance variable for this mouse here and now let's actually go back
and say this main activity that right fight here as you can see all of this constructed of this laptop
computer as you can see MacBook Pro high quality screen physical keyboard physical mouse.
This is the value of this superpower's 2008 on here.
As you can see this is the value of their RAM.
Fifteen hundred.
OK high quality touchpad.
OK.
And as you can see here smartphone computer and here I am instantiating these objects.
IPhone 6 is retina screen virtual keyboard all US 500 400.
OK.
And we have a tablet computer object.
And here as you can see I am instantiating this object i-Pad as you can see it retina screen virtual
keyboard all us eight hundred seven hundred ten.
So this then is for the screen size.
As you can see here.
So hopefully that makes sense.
And now the circuitry to output these objects to the screen.
So as you can see here I paste.
I actually pasted these lines of code here and now as you can see I referred to the name of this object
DXi desktop computer performance.
That said text performance as you can see plus desktop computer here I referred to the name of this
object this computer data evaluates performance.
So here I am actually calling this method on this object plus a new line character and again takes the
laptop computer performance that takes performance plus laptop computer that evaluates performance plus
a newline character takes the smartphone computer performance.
That's text preferments plus smartphone computer that evaluates performance plus a newline character
takes the tablet computer preferments that's a text preferments Plus a tablet computer that evaluates
performance plus a newline character.
So now let's actually get our project and see what happens.
OK so now as you can see our application is running on the simulator and here as you can see desktop
computer performance is disvalue laptop computer performance is disvalue smartphone computer as you
can see performance this value and tablets computer performance disvalue OK.
So hopefully that makes sense.
And now let's get you to go back inside this main activity that will find here.
And now let's actually put in some other lines of code here.
So here I'm going to actually paste in some lines of code here and then I'm going to explain to you
what's going on here.
OK.
So here as you can see in line for free I created an array of computer objects.
OK I just said that we have an array of computers.
OK but.
And the size of this area is four.
So this means that this area actually exits for a values of type computer object.
OK but in this line of code we didn't actually assign any value to these to this address.
OK.
And 11:44.
I said that computers sup index zero as you can see here.
This is the next zero.
Is this top computer.
So I assigned this object to this computer to the index zero of this Adley computer.
OK.
And here I said computed is sub index one as you can see here.
Assignment operator laptop computer.
So I assigned a laptop computer to the index number of one of these computer.
And here I actually assigned our smartphone computed object on this in this on to this index 0 to the
index.
And number two of these of these computers Aure.
OK.
And here I assigned a tablet computer object to these to the index number three of these are computers
at 8.
So remember that if you have an array of computers OK you have an array of computer objects.
OK.
And because there is actually an is a relationship between these objects and this computer.
For example as you can see this top computer is actually a computer OK laptop computer is a computer
smartphone computer is a computer and tablet computer is actually a smartphone computer.
So because smartphone computer is actually a computer a tablet computer is also a computer.
So that's why we could actually create an array of computers here.
And we said that the size of this area is four.
And here we could we could actually assign these values these objects to indexes of this Aure which
is actually offtake computer.
OK.
So that's the power of polymorphism in Java.
OK so now let's actually create a for loop inside of these are inside of this main activity class here.
OK.
And then I'm going to explain to you what's going on here.
So as you can see here this is my full loop.
OK.
And here this is this.
This is actually an enhanced for loop computer computer.
And here I want to actually iterate over the values that are inside of this array.
OK.
For example this desktop computer laptop computer smartphone computer and tablet computer.
And here as you can see I created an if statement if the value of a computer object as you can see here
this is a variable of type computer.
If this value is actually an instance of this computer.
OK so here we are iterating over the values that are actually inside of these computers.
OK so if this value your computer is actually an instance of this desktop computer then here you are
actually creating an object of type this that computer.
Ok this computer and the name of this object is current desktop computer assignment operator.
And here we are actually casting this object this computer object to our desktop computer.
OK.
So and here in line 54 we said that this computer that said text CONAN This current this that computer
that was strange.
OK.
And we have another if statement if computer is instance of actually laptop computer.
OK.
If this object is actually of type laptop computer here again we created another laptop the computer
object Cullens a laptop computer assignment operator.
And here again we are actually casting this object which is actually a computer.
We are actually downcasting.
OK.
We are done testing means casting an object from our superclass to where sockless.
OK so this computer actually is actually a superclass of this laptop computer.
OK.
So here we could actually cast downcasting object to a laptop computer and then assign that value to
this current laptop computer object.
And here in line 58 as you can see it says the the laptop computer that said text current laptop computer
object.
OK that was strange.
So we are actually calling this to same effect on this object.
And here we have another statement.
If computer is actually an instance of this smartphone computer class as you can see here and here we
actually create an object from the smartphone a computer class assignment operator.
And here we are actually casting this object to our smartphone our computer object as you can see here
and he had said that the smart phone computer that said text current smartphone computer that was three.
And here again we actually created another if statement if computer is actually an instance of these
tablets computer as you can see here.
So here we actually created an object of type tablet computer colorant tablet computer assignment operator.
And here we're actually casting this object this computer object to our tablet computer.
And here we are saying that the tablet computer that a text current tablet computer that is strange.
OK.
So hopefully that makes sense.
And let's actually run our project and see what happens.
So as you can see here our application is running on this emulator.
So there's that computer I imagine high quality screen physical keyboard.
So if you have this rally around this value performance this value and we have a laptop computer might
work for a high quality screen physical keyboard touchpad high quality touchpad mouse physical mouse
performance this value.
And we have our smartphone computer I-pads retina screen virtual keyboard Sebille power lamp screen
size performance.
We have a tablet computer or iPad retina screen virtual keyboard Sibiu power ram screen size performance.
OK.
So hopefully that makes sense.
And if you have any questions please post the discussion in the course and on and then I'll do my best
to answer all of your questions.
And thank you very much for watching and I'll see you in the next tutorial.