1
00:00:00,290 --> 00:00:03,150
So analysis actually putting some more lines of code here.

2
00:00:03,150 --> 00:00:10,000
So now when I actually create some objects from these classes that they actually created in this project.

3
00:00:10,110 --> 00:00:10,880
OK.

4
00:00:10,890 --> 00:00:14,440
So as you can see here these are the new lines of code that they actually pasted here.

5
00:00:14,460 --> 00:00:15,000
OK.

6
00:00:15,000 --> 00:00:21,150
The first object that I actually created is of type desktop computer and the name of this object is

7
00:00:21,150 --> 00:00:22,360
desktop computer.

8
00:00:22,530 --> 00:00:26,070
And here I put an assignment operator new this that computer.

9
00:00:26,070 --> 00:00:31,460
So here I'm going to instantiate this object by putting this new keyboard and here as you can see I

10
00:00:31,460 --> 00:00:37,420
need to actually passing some arguments to the constructor of this class and the name of.

11
00:00:37,440 --> 00:00:39,670
For example this computer is I-Max.

12
00:00:39,930 --> 00:00:46,020
And as you can see the screen is high quality screen physical keyboard and physical mouse.

13
00:00:46,170 --> 00:00:47,220
And this is the power.

14
00:00:47,220 --> 00:00:48,230
This is the super power.

15
00:00:48,240 --> 00:00:49,010
And this is the Ram.

16
00:00:49,170 --> 00:00:49,760
OK.

17
00:00:50,010 --> 00:00:51,850
And we have a laptop computer.

18
00:00:52,050 --> 00:00:55,710
And as you can see instantiating this laptop computer object.

19
00:00:55,710 --> 00:00:56,200
OK.

20
00:00:56,430 --> 00:01:01,980
And here we need to actually passing some values to the constructor of this laptop computer class match

21
00:01:01,980 --> 00:01:05,270
with prope high quality screen physical keyboard.

22
00:01:05,550 --> 00:01:09,880
And as you can see here and this laptop actually has a physical mouse.

23
00:01:10,090 --> 00:01:16,260
And here as you can see inside of this laptop computer inside of the constructor as you can see I actually

24
00:01:16,590 --> 00:01:21,750
specified that the constructor actually accepts a value of type strips 3.

25
00:01:21,960 --> 00:01:27,780
And the name of this argument is mouse and we can actually create an instance variable for this mouse

26
00:01:27,900 --> 00:01:28,670
here.

27
00:01:28,670 --> 00:01:33,660
Private's OK and strange mouse.

28
00:01:33,870 --> 00:01:39,840
And then here I can actually instantiate this mouse here and here inside of this constructor.

29
00:01:39,960 --> 00:01:45,100
I can't just type in this dot mouse assignment operator mouse.

30
00:01:45,180 --> 00:01:51,210
And now let's actually create a getter and the setter for this mouse instance variable.

31
00:01:51,210 --> 00:01:59,250
So inside of this class click here and then click on generates and then click on getter and setter mouse

32
00:02:00,030 --> 00:02:01,660
and then click on finish.

33
00:02:01,950 --> 00:02:09,750
So as you can see here we have a getter and setter for this mouse instance variable and inside of this

34
00:02:09,840 --> 00:02:14,410
and inside of these two string Meffert they can actually putting a person is here.

35
00:02:14,690 --> 00:02:17,700
OK in person yes.

36
00:02:18,240 --> 00:02:23,820
And now after this get touchpad here I can just put in a come up here and that I put into double coats

37
00:02:24,420 --> 00:02:33,120
and I can just typing mouse OK karma gets mouse OK.

38
00:02:33,550 --> 00:02:39,280
So this person as here is for this string value and this person is for this gets mouse he had as you

39
00:02:39,280 --> 00:02:40,120
can see here.

40
00:02:40,390 --> 00:02:45,130
OK this is the method that returns the value of this mouse instance variable.

41
00:02:45,190 --> 00:02:53,020
So I forgot to actually create an instance variable for this mouse here and now let's actually go back

42
00:02:53,020 --> 00:02:58,660
and say this main activity that right fight here as you can see all of this constructed of this laptop

43
00:02:58,660 --> 00:03:03,880
computer as you can see MacBook Pro high quality screen physical keyboard physical mouse.

44
00:03:03,880 --> 00:03:07,270
This is the value of this superpower's 2008 on here.

45
00:03:07,300 --> 00:03:11,730
As you can see this is the value of their RAM.

46
00:03:11,830 --> 00:03:12,700
Fifteen hundred.

47
00:03:12,740 --> 00:03:14,070
OK high quality touchpad.

48
00:03:14,080 --> 00:03:14,650
OK.

49
00:03:14,890 --> 00:03:19,980
And as you can see here smartphone computer and here I am instantiating these objects.

50
00:03:20,110 --> 00:03:25,930
IPhone 6 is retina screen virtual keyboard all US 500 400.

51
00:03:26,070 --> 00:03:26,880
OK.

52
00:03:27,040 --> 00:03:29,270
And we have a tablet computer object.

53
00:03:29,410 --> 00:03:35,860
And here as you can see I am instantiating this object i-Pad as you can see it retina screen virtual

54
00:03:35,860 --> 00:03:39,700
keyboard all us eight hundred seven hundred ten.

55
00:03:39,700 --> 00:03:41,740
So this then is for the screen size.

56
00:03:41,830 --> 00:03:42,940
As you can see here.

57
00:03:43,360 --> 00:03:45,040
So hopefully that makes sense.

58
00:03:45,220 --> 00:03:48,230
And now the circuitry to output these objects to the screen.

59
00:03:48,310 --> 00:03:50,260
So as you can see here I paste.

60
00:03:50,320 --> 00:03:56,050
I actually pasted these lines of code here and now as you can see I referred to the name of this object

61
00:03:56,380 --> 00:03:58,740
DXi desktop computer performance.

62
00:03:58,780 --> 00:04:04,600
That said text performance as you can see plus desktop computer here I referred to the name of this

63
00:04:04,600 --> 00:04:07,830
object this computer data evaluates performance.

64
00:04:07,840 --> 00:04:13,930
So here I am actually calling this method on this object plus a new line character and again takes the

65
00:04:13,930 --> 00:04:21,310
laptop computer performance that takes performance plus laptop computer that evaluates performance plus

66
00:04:21,400 --> 00:04:25,420
a newline character takes the smartphone computer performance.

67
00:04:25,430 --> 00:04:32,680
That's text preferments plus smartphone computer that evaluates performance plus a newline character

68
00:04:33,030 --> 00:04:40,270
takes the tablet computer preferments that's a text preferments Plus a tablet computer that evaluates

69
00:04:40,270 --> 00:04:42,360
performance plus a newline character.

70
00:04:42,460 --> 00:04:45,480
So now let's actually get our project and see what happens.

71
00:04:45,610 --> 00:04:51,700
OK so now as you can see our application is running on the simulator and here as you can see desktop

72
00:04:51,700 --> 00:04:58,930
computer performance is disvalue laptop computer performance is disvalue smartphone computer as you

73
00:04:58,930 --> 00:05:04,700
can see performance this value and tablets computer performance disvalue OK.

74
00:05:04,960 --> 00:05:06,780
So hopefully that makes sense.

75
00:05:06,780 --> 00:05:10,340
And now let's get you to go back inside this main activity that will find here.

76
00:05:10,510 --> 00:05:13,210
And now let's actually put in some other lines of code here.

77
00:05:13,210 --> 00:05:18,460
So here I'm going to actually paste in some lines of code here and then I'm going to explain to you

78
00:05:18,460 --> 00:05:19,550
what's going on here.

79
00:05:19,570 --> 00:05:20,350
OK.

80
00:05:20,680 --> 00:05:27,610
So here as you can see in line for free I created an array of computer objects.

81
00:05:27,640 --> 00:05:31,490
OK I just said that we have an array of computers.

82
00:05:31,630 --> 00:05:32,520
OK but.

83
00:05:32,660 --> 00:05:34,870
And the size of this area is four.

84
00:05:34,870 --> 00:05:40,290
So this means that this area actually exits for a values of type computer object.

85
00:05:40,300 --> 00:05:47,000
OK but in this line of code we didn't actually assign any value to these to this address.

86
00:05:47,020 --> 00:05:47,520
OK.

87
00:05:47,710 --> 00:05:49,100
And 11:44.

88
00:05:49,190 --> 00:05:52,900
I said that computers sup index zero as you can see here.

89
00:05:52,990 --> 00:05:54,040
This is the next zero.

90
00:05:54,280 --> 00:05:55,570
Is this top computer.

91
00:05:55,570 --> 00:06:02,040
So I assigned this object to this computer to the index zero of this Adley computer.

92
00:06:02,290 --> 00:06:02,820
OK.

93
00:06:02,980 --> 00:06:07,240
And here I said computed is sub index one as you can see here.

94
00:06:07,300 --> 00:06:09,460
Assignment operator laptop computer.

95
00:06:09,460 --> 00:06:13,930
So I assigned a laptop computer to the index number of one of these computer.

96
00:06:14,020 --> 00:06:23,200
And here I actually assigned our smartphone computed object on this in this on to this index 0 to the

97
00:06:23,200 --> 00:06:23,570
index.

98
00:06:23,570 --> 00:06:26,150
And number two of these of these computers Aure.

99
00:06:26,200 --> 00:06:26,750
OK.

100
00:06:26,980 --> 00:06:33,550
And here I assigned a tablet computer object to these to the index number three of these are computers

101
00:06:33,580 --> 00:06:34,080
at 8.

102
00:06:34,090 --> 00:06:40,620
So remember that if you have an array of computers OK you have an array of computer objects.

103
00:06:40,630 --> 00:06:41,200
OK.

104
00:06:41,380 --> 00:06:46,780
And because there is actually an is a relationship between these objects and this computer.

105
00:06:46,780 --> 00:06:54,760
For example as you can see this top computer is actually a computer OK laptop computer is a computer

106
00:06:55,090 --> 00:07:01,000
smartphone computer is a computer and tablet computer is actually a smartphone computer.

107
00:07:01,000 --> 00:07:06,820
So because smartphone computer is actually a computer a tablet computer is also a computer.

108
00:07:06,850 --> 00:07:12,310
So that's why we could actually create an array of computers here.

109
00:07:12,400 --> 00:07:14,400
And we said that the size of this area is four.

110
00:07:14,500 --> 00:07:19,570
And here we could we could actually assign these values these objects to indexes of this Aure which

111
00:07:19,570 --> 00:07:21,140
is actually offtake computer.

112
00:07:21,310 --> 00:07:21,840
OK.

113
00:07:21,940 --> 00:07:24,990
So that's the power of polymorphism in Java.

114
00:07:25,150 --> 00:07:32,240
OK so now let's actually create a for loop inside of these are inside of this main activity class here.

115
00:07:32,410 --> 00:07:32,970
OK.

116
00:07:33,340 --> 00:07:35,670
And then I'm going to explain to you what's going on here.

117
00:07:35,920 --> 00:07:37,880
So as you can see here this is my full loop.

118
00:07:37,960 --> 00:07:38,600
OK.

119
00:07:38,830 --> 00:07:39,950
And here this is this.

120
00:07:39,960 --> 00:07:43,750
This is actually an enhanced for loop computer computer.

121
00:07:43,780 --> 00:07:47,930
And here I want to actually iterate over the values that are inside of this array.

122
00:07:47,980 --> 00:07:48,620
OK.

123
00:07:48,760 --> 00:07:53,590
For example this desktop computer laptop computer smartphone computer and tablet computer.

124
00:07:53,590 --> 00:07:59,470
And here as you can see I created an if statement if the value of a computer object as you can see here

125
00:07:59,480 --> 00:08:01,840
this is a variable of type computer.

126
00:08:01,870 --> 00:08:05,840
If this value is actually an instance of this computer.

127
00:08:05,890 --> 00:08:11,140
OK so here we are iterating over the values that are actually inside of these computers.

128
00:08:11,170 --> 00:08:17,560
OK so if this value your computer is actually an instance of this desktop computer then here you are

129
00:08:17,560 --> 00:08:21,060
actually creating an object of type this that computer.

130
00:08:21,130 --> 00:08:27,420
Ok this computer and the name of this object is current desktop computer assignment operator.

131
00:08:27,640 --> 00:08:33,230
And here we are actually casting this object this computer object to our desktop computer.

132
00:08:33,340 --> 00:08:33,910
OK.

133
00:08:34,210 --> 00:08:42,100
So and here in line 54 we said that this computer that said text CONAN This current this that computer

134
00:08:42,130 --> 00:08:43,160
that was strange.

135
00:08:43,360 --> 00:08:43,830
OK.

136
00:08:44,020 --> 00:08:50,820
And we have another if statement if computer is instance of actually laptop computer.

137
00:08:50,860 --> 00:08:51,260
OK.

138
00:08:51,370 --> 00:08:57,750
If this object is actually of type laptop computer here again we created another laptop the computer

139
00:08:57,790 --> 00:09:01,210
object Cullens a laptop computer assignment operator.

140
00:09:01,480 --> 00:09:05,870
And here again we are actually casting this object which is actually a computer.

141
00:09:06,010 --> 00:09:07,230
We are actually downcasting.

142
00:09:07,240 --> 00:09:07,720
OK.

143
00:09:07,870 --> 00:09:13,550
We are done testing means casting an object from our superclass to where sockless.

144
00:09:13,570 --> 00:09:18,190
OK so this computer actually is actually a superclass of this laptop computer.

145
00:09:18,190 --> 00:09:18,590
OK.

146
00:09:18,700 --> 00:09:23,530
So here we could actually cast downcasting object to a laptop computer and then assign that value to

147
00:09:23,530 --> 00:09:25,680
this current laptop computer object.

148
00:09:25,780 --> 00:09:32,200
And here in line 58 as you can see it says the the laptop computer that said text current laptop computer

149
00:09:32,230 --> 00:09:32,730
object.

150
00:09:32,760 --> 00:09:33,900
OK that was strange.

151
00:09:33,910 --> 00:09:37,190
So we are actually calling this to same effect on this object.

152
00:09:37,240 --> 00:09:39,060
And here we have another statement.

153
00:09:39,100 --> 00:09:46,300
If computer is actually an instance of this smartphone computer class as you can see here and here we

154
00:09:46,300 --> 00:09:51,900
actually create an object from the smartphone a computer class assignment operator.

155
00:09:52,030 --> 00:09:58,820
And here we are actually casting this object to our smartphone our computer object as you can see here

156
00:09:59,470 --> 00:10:05,580
and he had said that the smart phone computer that said text current smartphone computer that was three.

157
00:10:05,830 --> 00:10:12,160
And here again we actually created another if statement if computer is actually an instance of these

158
00:10:12,160 --> 00:10:14,530
tablets computer as you can see here.

159
00:10:14,530 --> 00:10:21,110
So here we actually created an object of type tablet computer colorant tablet computer assignment operator.

160
00:10:21,190 --> 00:10:26,230
And here we're actually casting this object this computer object to our tablet computer.

161
00:10:26,230 --> 00:10:32,730
And here we are saying that the tablet computer that a text current tablet computer that is strange.

162
00:10:33,070 --> 00:10:33,770
OK.

163
00:10:34,030 --> 00:10:36,660
So hopefully that makes sense.

164
00:10:36,910 --> 00:10:40,870
And let's actually run our project and see what happens.

165
00:10:40,990 --> 00:10:45,040
So as you can see here our application is running on this emulator.

166
00:10:45,040 --> 00:10:49,130
So there's that computer I imagine high quality screen physical keyboard.

167
00:10:49,330 --> 00:10:56,540
So if you have this rally around this value performance this value and we have a laptop computer might

168
00:10:56,610 --> 00:11:03,370
work for a high quality screen physical keyboard touchpad high quality touchpad mouse physical mouse

169
00:11:03,520 --> 00:11:05,270
performance this value.

170
00:11:05,470 --> 00:11:12,100
And we have our smartphone computer I-pads retina screen virtual keyboard Sebille power lamp screen

171
00:11:12,100 --> 00:11:13,730
size performance.

172
00:11:13,780 --> 00:11:21,890
We have a tablet computer or iPad retina screen virtual keyboard Sibiu power ram screen size performance.

173
00:11:22,270 --> 00:11:23,090
OK.

174
00:11:23,440 --> 00:11:25,130
So hopefully that makes sense.

175
00:11:25,240 --> 00:11:30,460
And if you have any questions please post the discussion in the course and on and then I'll do my best

176
00:11:30,460 --> 00:11:32,440
to answer all of your questions.

177
00:11:32,810 --> 00:11:36,760
And thank you very much for watching and I'll see you in the next tutorial.

