1
00:00:00,600 --> 00:00:06,550
And now want to actually output the tutoring method that is related to these objects here.

2
00:00:06,660 --> 00:00:06,970
OK.

3
00:00:06,980 --> 00:00:13,740
So now I want to actually output these objects to the screen by calling them if it was trained on these

4
00:00:13,740 --> 00:00:14,400
objects.

5
00:00:14,430 --> 00:00:15,070
OK.

6
00:00:15,390 --> 00:00:20,550
So here I can just type in the anemone that said text.

7
00:00:21,240 --> 00:00:26,250
And inside the prentices I can just referred to the name of this object anemone.

8
00:00:26,540 --> 00:00:27,110
OK.

9
00:00:27,310 --> 00:00:29,230
That is strange.

10
00:00:29,370 --> 00:00:34,770
So here I want to actually call the twisting method that is inside of this animal class as you can see

11
00:00:34,770 --> 00:00:40,920
we have our twisting my foot here inside of this animal class and here I want to call this method to

12
00:00:40,920 --> 00:00:42,650
this animate object.

13
00:00:42,690 --> 00:00:51,210
And here again I want to type into the lion that sit text and inside the practices of the set text here

14
00:00:51,540 --> 00:00:56,780
I need to refer to the name of this object lion that is three in my faith.

15
00:00:57,000 --> 00:01:03,340
And as you can see here we have our twisting my head actually over right at the Smurfette in say this

16
00:01:03,340 --> 00:01:09,720
like in class and you want to actually call the Smurfette Andi's like an object.

17
00:01:09,720 --> 00:01:12,930
So now let's actually run our project and see what happens.

18
00:01:12,930 --> 00:01:16,490
So now as you can see our application actually crashed.

19
00:01:16,500 --> 00:01:16,940
OK.

20
00:01:17,020 --> 00:01:20,180
Unfortunately I have 27 has stopped.

21
00:01:20,250 --> 00:01:22,520
So let's actually go inside this log here.

22
00:01:22,620 --> 00:01:23,320
OK.

23
00:01:23,730 --> 00:01:33,810
And here as you can see it says that land does illegal argument exception the value of the power must

24
00:01:33,810 --> 00:01:34,980
be greater than zero.

25
00:01:35,070 --> 00:01:41,230
So this is the exception that you actually created here inside this Animal class.

26
00:01:41,250 --> 00:01:47,870
I said that if the value of this power valuable is less than or equal to number 0 then for this legal

27
00:01:47,940 --> 00:01:52,520
argument exception the value of the power must be greater than number 0.

28
00:01:52,860 --> 00:01:57,080
So here this is how actually the exceptions work in your projects.

29
00:01:57,090 --> 00:01:57,460
OK.

30
00:01:57,540 --> 00:02:02,960
I need to actually change these values to other values so I can't just take in for example Number two

31
00:02:02,960 --> 00:02:07,720
hundred for the power and number three hundred for the speed.

32
00:02:07,890 --> 00:02:11,820
And here as you can see I need to change these numbers.

33
00:02:11,820 --> 00:02:16,590
For example number 400 power and number 700 for this speed.

34
00:02:16,860 --> 00:02:20,100
And now if I hit on my project let's see what happens.

35
00:02:20,100 --> 00:02:26,640
So now as you can see our project actually our application is running on this emulator and here it says

36
00:02:26,750 --> 00:02:33,630
animal named Bear animal color black animal power 200 and animal speed is 300.

37
00:02:33,900 --> 00:02:42,030
And here it says animal named my lion animal color yellow animal power 400 animal species 700.

38
00:02:42,150 --> 00:02:48,680
And here it says can are lying and fight through the fighting power of our lion is one hundred and seventy.

39
00:02:48,720 --> 00:02:49,930
OK.

40
00:02:50,010 --> 00:02:52,020
So hopefully death makes sense.

41
00:02:52,020 --> 00:02:55,910
Let's actually use the power of putting morphism in Java.

42
00:02:56,020 --> 00:03:00,800
OK here let's actually create an animal object.

43
00:03:00,920 --> 00:03:02,020
Animal.

44
00:03:02,690 --> 00:03:03,220
OK.

45
00:03:03,540 --> 00:03:07,410
So I actually referred to the name of this Animal class.

46
00:03:07,410 --> 00:03:16,410
And here I want to actually give a name to this animal object my animal OK assignment operator and now

47
00:03:16,620 --> 00:03:19,830
I want to refer to the name of this lion object OK.

48
00:03:20,220 --> 00:03:20,690
Lion.

49
00:03:20,730 --> 00:03:27,810
So here as you can see I actually created an object from this animal class but here after the assignment

50
00:03:27,840 --> 00:03:30,450
operator it refers to the name of this object.

51
00:03:30,450 --> 00:03:31,560
OK.

52
00:03:31,560 --> 00:03:38,730
So because there is actually an ease our relationship between these lion class and this animal class

53
00:03:38,790 --> 00:03:44,510
because this lion class actually inherits all of the features and behaviors that is actually in say

54
00:03:44,520 --> 00:03:49,110
that this animal class there is an is a relationship between these two classes.

55
00:03:49,110 --> 00:03:49,690
OK.

56
00:03:49,920 --> 00:03:56,040
So here I could actually refer to the name of this object the name of this line object and then assign

57
00:03:56,050 --> 00:03:57,980
that object to this animal object.

58
00:03:58,020 --> 00:04:00,420
Here to this animal is valuable.

59
00:04:00,620 --> 00:04:01,290
OK.

60
00:04:01,530 --> 00:04:09,450
Because that is and actually is a relationship between this animal class and this lion class ok at compile

61
00:04:09,450 --> 00:04:09,780
time.

62
00:04:09,780 --> 00:04:10,510
It is OK.

63
00:04:10,530 --> 00:04:16,760
We can actually assign this value because that is an is a relationship between these two classes like

64
00:04:16,750 --> 00:04:23,190
in an animal and we could actually we can actually assign these lion objects to this animal.

65
00:04:23,390 --> 00:04:24,450
Valuable here.

66
00:04:24,540 --> 00:04:24,980
OK.

67
00:04:25,110 --> 00:04:28,100
Lion is actually an animal.

68
00:04:28,170 --> 00:04:28,860
OK.

69
00:04:29,220 --> 00:04:33,450
So I actually assigned this object to this animal variable.

70
00:04:33,780 --> 00:04:38,120
And now let's actually output this object to this.

71
00:04:38,160 --> 00:04:43,610
OK so here I can just take anti-X the polymorphism that said text.

72
00:04:43,620 --> 00:04:49,360
And now inside the practices I can just type in my animal that string.

73
00:04:49,710 --> 00:04:56,400
So because I actually fell to the name of this animal object here as you can see this animal ridable

74
00:04:56,700 --> 00:05:02,780
you may think that it's going to actually whistling method that is inside of this animal class.

75
00:05:02,780 --> 00:05:03,600
OK.

76
00:05:04,130 --> 00:05:09,860
But it's going to actually call the two thing Meffert that is inside of this lion class.

77
00:05:09,860 --> 00:05:10,120
OK.

78
00:05:10,130 --> 00:05:15,620
As you can see we have a history of it in say that we live in class because at runtime it's going to

79
00:05:15,620 --> 00:05:22,460
refer to this object located like an object that we actually assign to this animal and are variable

80
00:05:22,460 --> 00:05:22,880
here.

81
00:05:22,880 --> 00:05:23,380
OK.

82
00:05:23,540 --> 00:05:25,820
So let's start on our project and see what happens.

83
00:05:25,820 --> 00:05:32,450
So now as you can see our application is running on this emulator and here it says liar.

84
00:05:32,480 --> 00:05:41,120
Using polymorphism monkey animal name my lion animal color yellow animal power 400 animal speed 700.

85
00:05:41,290 --> 00:05:45,270
Can our lion fight through the fighting power over a lion.

86
00:05:45,320 --> 00:05:49,910
One hundred and seventy all though we actually created an object from the Animal class.

87
00:05:49,940 --> 00:05:56,960
OK here because we actually assign this like an object to this valuable at runtime it's going to actually

88
00:05:56,960 --> 00:06:00,900
call the twisting method that is related to this like an object.

89
00:06:00,890 --> 00:06:01,260
OK.

90
00:06:01,340 --> 00:06:04,150
Because it's going to actually feel like an object.

91
00:06:04,440 --> 00:06:04,770
OK.

92
00:06:04,790 --> 00:06:07,440
That's the power of polymorphism then in Java.

93
00:06:07,690 --> 00:06:09,420
And hopefully that makes sense.

94
00:06:09,530 --> 00:06:14,480
And if you have any questions please post the discussion of the course and if you do not understand

95
00:06:14,510 --> 00:06:20,360
the inheritance in Java Please watch their inheritance section of this course again.

96
00:06:20,360 --> 00:06:26,200
So now let's actually go back and say this content underline the example and then here I need to actually

97
00:06:26,200 --> 00:06:32,870
click on this clear cast here and now I need to actually drag a large takes you into this scroll you

98
00:06:32,870 --> 00:06:33,250
here.

99
00:06:33,260 --> 00:06:38,810
So here inside of this componentry section here inside this linearly sweaty call that's actually right

100
00:06:38,910 --> 00:06:44,540
a large takes you into this linearly aesthetical that is inside of this vertical scroll view here.

101
00:06:44,560 --> 00:06:51,700
OK and double click on it and delete the text of this text view and for the ID just type in here takes

102
00:06:51,800 --> 00:06:56,690
the chats OK and then press Enter key on your keyboard.

103
00:06:56,690 --> 00:07:02,150
So now let's actually go back and say this main activity the job right here and now let's actually create

104
00:07:02,240 --> 00:07:09,530
an object from the sticks class so takes you the chat's assignment operator.

105
00:07:09,710 --> 00:07:18,210
And then I need to test this object to a text view object find view by id r that Id dot TDX the checked

106
00:07:18,340 --> 00:07:22,310
OK and then I need to put in a semi-colon at the end of my statement here.

107
00:07:22,310 --> 00:07:26,760
OK so now let's actually create an object from this chat class.

108
00:07:26,780 --> 00:07:28,380
So I just need to type in here Chad.

109
00:07:28,550 --> 00:07:31,390
And the name of this object is my chats.

110
00:07:31,440 --> 00:07:40,040
OK assignments operator new chats and here I need to specify some arguments for the constructor of this

111
00:07:40,540 --> 00:07:41,400
chat class here.

112
00:07:41,420 --> 00:07:43,070
As you can see chat object.

113
00:07:43,400 --> 00:07:47,350
So for the name of this cat just type in here my chat.

114
00:07:47,460 --> 00:07:54,030
OK comma the color of my child is for example black or white.

115
00:07:54,490 --> 00:08:03,170
Ok come up and the power of my child is for example 400 comma and the speed of my cat is for example

116
00:08:03,310 --> 00:08:04,150
seven hundred.

117
00:08:04,160 --> 00:08:04,660
OK.

118
00:08:04,850 --> 00:08:08,430
And then I need to put in a semicolon at the end of my statement here.

119
00:08:08,810 --> 00:08:10,160
So now it's actually Outsports.

120
00:08:10,160 --> 00:08:11,650
This cat is my cat.

121
00:08:11,660 --> 00:08:15,880
Object to the screen so I just need to take it here to the chat.

122
00:08:16,010 --> 00:08:20,150
That said text my child's dot two is three.

123
00:08:20,430 --> 00:08:24,190
OK so now let's execute on our project and see what happens.

124
00:08:24,260 --> 00:08:30,830
So now as you can see our application is running on DS emulator and if you scroll down here you can

125
00:08:30,830 --> 00:08:32,270
see it says cats.

126
00:08:32,630 --> 00:08:34,130
Animal named my chats.

127
00:08:34,310 --> 00:08:35,120
OK.

128
00:08:35,120 --> 00:08:40,390
So it is actually calling the 2st Meffert that is inside of this cat class yellow cake Chatz animal

129
00:08:40,400 --> 00:08:46,410
name my cat animal color of white animal power 400 an animal speed seven hundred.

130
00:08:46,430 --> 00:08:51,670
OK so now let's actually delete this line of code here first.

131
00:08:51,760 --> 00:08:52,280
OK.

132
00:08:52,610 --> 00:08:56,040
And then this actually creates an object from the Animal class.

133
00:08:56,060 --> 00:08:57,050
OK.

134
00:08:57,770 --> 00:09:02,730
And the name of my animal is for example my animal too.

135
00:09:02,940 --> 00:09:03,610
OK.

136
00:09:03,990 --> 00:09:11,260
Assignment operator my chats my chats and put a semi-colon at the end of your statement here.

137
00:09:11,510 --> 00:09:16,460
OK so now listen to that Outsports this my animal to this clean.

138
00:09:16,460 --> 00:09:16,820
OK.

139
00:09:16,850 --> 00:09:20,310
So just they can hear the cat that said Tick's.

140
00:09:20,330 --> 00:09:26,690
So say that the Prentice's of this set takes Smurfette just referred to the name of this animal to object

141
00:09:27,080 --> 00:09:28,900
dot to a string.

142
00:09:29,420 --> 00:09:33,890
So now let's actually again run our project and see what happens.

143
00:09:33,890 --> 00:09:34,350
OK.

144
00:09:34,430 --> 00:09:38,410
Now as you can see our application is running on this emulator here.

145
00:09:38,630 --> 00:09:42,480
And here you can see again the string Meffert that is inside of this.

146
00:09:42,500 --> 00:09:48,740
Inside this cat class is being called the cat's animal name my cats animal color white animal power

147
00:09:48,750 --> 00:09:51,890
400 and animal speed is 700.

148
00:09:51,890 --> 00:09:57,490
So as you can see here first of all they created an object from this cat's class called my Chatz.

149
00:09:57,610 --> 00:10:03,950
OK in inline first T6 I actually created another object from this animal class and the name of this

150
00:10:03,950 --> 00:10:05,760
object is my animal too.

151
00:10:06,050 --> 00:10:06,580
OK.

152
00:10:06,770 --> 00:10:12,580
And here I put an assignment operator and then I referred to the name of this my chat's object.

153
00:10:12,860 --> 00:10:17,410
And I assigned this object to this value to this animal valuable here my animal too.

154
00:10:17,540 --> 00:10:18,230
OK.

155
00:10:18,320 --> 00:10:25,220
And 11:57 I actually called these two string Mefford on this my animal to object as you can see but

156
00:10:25,250 --> 00:10:27,720
at runtime as you can see here.

157
00:10:27,920 --> 00:10:33,680
It actually called this 2st Merfeld that is actually inside of these chats class.

158
00:10:34,000 --> 00:10:34,600
OK.

159
00:10:34,700 --> 00:10:39,610
Because that's right because at runtime it's going to actually refer to this object.

160
00:10:39,640 --> 00:10:40,550
Keep my Chatz.

161
00:10:40,690 --> 00:10:41,000
OK.

162
00:10:41,000 --> 00:10:47,460
And then it's going to call this the string Meffert that is inside of these chats class.

163
00:10:47,500 --> 00:10:52,810
It's actually called the twisting method that is actually related to this object.

164
00:10:52,970 --> 00:10:54,890
And then we can see these values here.

165
00:10:55,000 --> 00:10:55,460
OK.

166
00:10:55,520 --> 00:11:00,440
So again that's the power of polymorphism and I hopefully that makes sense.

167
00:11:00,440 --> 00:11:05,750
And if you have any questions about polymorphism then please post the discussion in the course and then

168
00:11:05,810 --> 00:11:08,420
I'll do my best to answer all of your questions.

169
00:11:08,790 --> 00:11:13,370
And thank you very much for watching and I'll see you in the next tutorial.

