1
00:00:00,630 --> 00:00:09,420
And as you can see here inside this main class here we are actually creating an object from these chat

2
00:00:09,420 --> 00:00:11,530
class called Cat 1.

3
00:00:11,850 --> 00:00:18,000
And here we are actually passing some values to the constructor of this cat class.

4
00:00:18,060 --> 00:00:24,180
As you can see whenever we create an object from this track class the constructor of this cat class

5
00:00:24,180 --> 00:00:25,100
is going to be called.

6
00:00:25,110 --> 00:00:25,710
OK.

7
00:00:25,800 --> 00:00:30,130
So as you can see here you are actually passing the name of this chat.

8
00:00:30,450 --> 00:00:33,610
And here we are actually passing the color of this card.

9
00:00:33,720 --> 00:00:40,200
The amount of speed of this card the amount of power of this card and this value is for the number of

10
00:00:40,200 --> 00:00:48,060
legs of this cat and this value is for the can hunt other animals instance variable A-okay which we

11
00:00:48,060 --> 00:00:50,010
actually passed the true value.

12
00:00:50,340 --> 00:00:58,920
And here in line 52 we are actually trying to output these values to the screen by calling this to a

13
00:00:58,930 --> 00:01:04,460
string Mefford which we actually overnighted inside this cat class as you can see here.

14
00:01:04,560 --> 00:01:12,090
We actually overgraded this to a string Meffert in order to create a human readable description of DS

15
00:01:12,320 --> 00:01:16,930
for instance variables and then outputs of those values to the screen here.

16
00:01:17,010 --> 00:01:19,560
As you can see here chat's 1:59 a string.

17
00:01:19,740 --> 00:01:23,790
So now let's actually run our project and see what happens.

18
00:01:23,790 --> 00:01:28,110
So as you can see here now these values are outputted to the screen.

19
00:01:28,140 --> 00:01:28,650
OK.

20
00:01:28,860 --> 00:01:33,780
The name of our cat is my cat the color of our cat is white.

21
00:01:33,780 --> 00:01:35,900
The speed of our cat is 40.

22
00:01:35,940 --> 00:01:38,290
The power of our cat is 50.

23
00:01:38,340 --> 00:01:40,950
Number of legs of our cat is four.

24
00:01:41,490 --> 00:01:43,590
And our cat can fight.

25
00:01:43,590 --> 00:01:44,900
OK a fight.

26
00:01:44,910 --> 00:01:45,410
True.

27
00:01:45,500 --> 00:01:46,120
OK.

28
00:01:46,260 --> 00:01:48,630
This means that our cat can fight.

29
00:01:48,660 --> 00:01:49,150
OK.

30
00:01:49,260 --> 00:01:55,240
So as you can see here now you can understand the power of inheritance in Java as you can see here inside

31
00:01:55,310 --> 00:01:56,300
it cat class.

32
00:01:56,310 --> 00:02:01,720
We deleted all of those duplicated codes that were inside this Chad class.

33
00:02:01,770 --> 00:02:02,370
OK.

34
00:02:02,580 --> 00:02:09,760
We just actually inheriting all of those features and behaviors that are inside this Animal class.

35
00:02:09,780 --> 00:02:10,150
OK.

36
00:02:10,170 --> 00:02:17,970
So we didn't need to actually redeclare the variables and the methods that were created inside this

37
00:02:18,270 --> 00:02:24,360
Animal class inside this Animal class we actually created this instance variables for example the name

38
00:02:24,360 --> 00:02:31,020
of our animal the color of our animal the amount of speed of our animal and the amount of power of our

39
00:02:31,020 --> 00:02:31,670
animal.

40
00:02:31,860 --> 00:02:37,920
And as you can see we created a constructor here and we actually initialized these instance variables

41
00:02:37,920 --> 00:02:45,690
here and we also created some getters and setters for these instance rally abettors and we we even created

42
00:02:45,960 --> 00:02:47,760
a shoestring team effort here.

43
00:02:48,150 --> 00:02:48,690
OK.

44
00:02:48,840 --> 00:02:55,200
At inciters twittering Meffert as you can see here we actually put our own codes in order to output

45
00:02:55,260 --> 00:02:56,850
these values to the screen.

46
00:02:57,030 --> 00:03:01,550
So inside this math class we actually put some duplicated codes here.

47
00:03:01,580 --> 00:03:05,740
We didn't need to actually implement some of these codes here.

48
00:03:05,970 --> 00:03:14,430
So now I want to show you how we can actually again use the power of inheritance in order to actually

49
00:03:14,730 --> 00:03:19,960
write less courts OK and write more maintainable codes.

50
00:03:19,980 --> 00:03:20,560
OK.

51
00:03:20,790 --> 00:03:28,200
So now I want to show you how you can actually delete those duplicated codes and write less codes and

52
00:03:28,320 --> 00:03:30,960
write more maintainable codes.

53
00:03:31,440 --> 00:03:32,380
OK everyone.

54
00:03:32,400 --> 00:03:38,700
Now let's actually delete these lines of code here because I want to show you how you can actually use

55
00:03:38,880 --> 00:03:41,640
the power of inheritance in your codes.

56
00:03:41,670 --> 00:03:47,670
So as you can see here inside this animal class we have this line of code here that is completely useful

57
00:03:47,880 --> 00:03:48,860
for our cat class.

58
00:03:48,870 --> 00:03:49,450
OK.

59
00:03:49,640 --> 00:03:55,650
This method actually outputs are the name of an object the color of an object the amount of speed of

60
00:03:55,650 --> 00:04:00,090
our object and also it outputs the amount of power of our object.

61
00:04:00,090 --> 00:04:00,990
OK.

62
00:04:01,200 --> 00:04:10,560
So here inside this math class in order to use the implementations that are in sight these are two string

63
00:04:10,570 --> 00:04:15,010
Mefford that is overrated inside these animal class.

64
00:04:15,270 --> 00:04:22,610
Inside this cat class inside these two string Meffert I can just type in return super.

65
00:04:22,630 --> 00:04:26,290
So remember this super refers to the superclass.

66
00:04:26,290 --> 00:04:30,770
So what is the superclass the superclass of this chat class is Animal class.

67
00:04:30,790 --> 00:04:31,540
OK.

68
00:04:31,990 --> 00:04:42,180
Return super dot to a string so as you can see here now we did manage to successfully refer to the codes

69
00:04:42,690 --> 00:04:47,520
that are inside these is Meffert inside this animal class.

70
00:04:47,550 --> 00:04:48,430
OK.

71
00:04:48,810 --> 00:04:54,220
So superior first to this animal class that was three in the first two this method and then it's going

72
00:04:54,220 --> 00:04:58,370
to actually execute these lines of code here inside these two a string Meffert.

73
00:04:58,380 --> 00:04:59,440
OK.

74
00:04:59,460 --> 00:05:04,160
So inside this cathe class we actually typed in here return super's that was Thring.

75
00:05:04,200 --> 00:05:04,690
OK.

76
00:05:04,830 --> 00:05:08,000
So let's actually run our project and see what happens.

77
00:05:08,130 --> 00:05:12,520
So as you can see here these are the values that are outputted to the screen.

78
00:05:12,540 --> 00:05:18,520
OK name my cats color white speed 40 powerful 80.

79
00:05:18,720 --> 00:05:25,500
So inside this main activity that java file here as you can see are actually specified some values for

80
00:05:25,500 --> 00:05:26,820
this cat object.

81
00:05:26,820 --> 00:05:34,650
And here as you can see in this emulator as you can see the name of my child is my cats the color of

82
00:05:34,650 --> 00:05:39,450
my cat is white and this is the value for my speed.

83
00:05:39,780 --> 00:05:42,440
And this is the value for the power of my cat.

84
00:05:42,720 --> 00:05:50,030
And we also actually specified two other values for my cat object which we can't actually see in the

85
00:05:50,080 --> 00:05:54,570
emulator how we can actually output these values to the screen.

86
00:05:54,570 --> 00:05:56,940
So and so it is Chatz class as you can see here.

87
00:05:56,970 --> 00:06:04,680
We did manage to actually use implementations that are inside the twisting Meffert inside this Animal

88
00:06:04,680 --> 00:06:06,810
class in our chat class.

89
00:06:06,810 --> 00:06:07,420
OK.

90
00:06:07,590 --> 00:06:10,020
By just typing super THAT WAS think OK.

91
00:06:10,030 --> 00:06:15,220
Superiorly first the superclass which is the Animal class that was three in the first two that westering

92
00:06:15,240 --> 00:06:17,780
Meffert that is inside the Animal class.

93
00:06:17,820 --> 00:06:18,270
OK.

94
00:06:18,330 --> 00:06:20,460
And here we actually used it.

95
00:06:20,460 --> 00:06:26,450
These are capabilities that are inside this Animal class but inside is Kathe class.

96
00:06:26,460 --> 00:06:32,300
We've got two other instance variables that are specific only to this class Class.

97
00:06:32,400 --> 00:06:33,300
OK.

98
00:06:33,690 --> 00:06:40,470
So in order to actually output these values to the screen here I can just put in a plus operator here.

99
00:06:41,410 --> 00:06:45,610
And then I can just type in strange dot format.

100
00:06:46,330 --> 00:06:55,090
And here first of all I can actually specify the formatting instructions here present as Colan percent

101
00:06:55,120 --> 00:07:00,550
the space per cent as Colan per cent B.

102
00:07:00,610 --> 00:07:03,970
And then I can actually specify the arguments.

103
00:07:03,970 --> 00:07:10,840
So for the first Torchin I need to actually specify I need to actually putting out an argument of types

104
00:07:10,850 --> 00:07:11,290
3.

105
00:07:11,320 --> 00:07:15,730
So I just put in a string literal here inside these double quotes.

106
00:07:15,730 --> 00:07:20,190
I can just type in number of legs.

107
00:07:20,470 --> 00:07:21,140
OK.

108
00:07:21,550 --> 00:07:27,180
And for this person D I need to actually specify an argument of type integer.

109
00:07:27,450 --> 00:07:28,100
OK.

110
00:07:28,150 --> 00:07:30,650
Number of legs.

111
00:07:30,880 --> 00:07:36,280
And then again I need to actually specify an argument of type string here.

112
00:07:36,310 --> 00:07:42,860
So as you can see here this percent as talken needs an argument of type string.

113
00:07:43,030 --> 00:07:45,000
So I just put in two double quotes here.

114
00:07:45,220 --> 00:07:55,770
So here I want to actually use a string literal again fight colon and then I refer to the name of my

115
00:07:55,770 --> 00:08:00,710
instance variable as you can see can hunt other animals.

116
00:08:00,720 --> 00:08:01,330
OK.

117
00:08:01,440 --> 00:08:07,840
So as you can see here we've got this person's behere and this token is for values of type Boolean.

118
00:08:07,860 --> 00:08:13,390
OK Chad hunt other animals so let's actually run our project and see what happens.

119
00:08:13,560 --> 00:08:21,330
So as you can see here now these values are out here a number of legs for fight true so we can actually

120
00:08:21,330 --> 00:08:23,310
put a space between these two values.

121
00:08:23,310 --> 00:08:27,680
Number 30 and this number of legs a string literal here.

122
00:08:27,690 --> 00:08:34,310
So inside this animal class here I can actually put a space after this person D here and if I don't

123
00:08:34,350 --> 00:08:35,380
my project again.

124
00:08:35,670 --> 00:08:39,210
Now we can't see a space between these two values.

125
00:08:39,210 --> 00:08:40,020
OK.

126
00:08:40,170 --> 00:08:42,510
Number fretty our space.

127
00:08:42,510 --> 00:08:43,230
Number of legs.

128
00:08:43,230 --> 00:08:44,240
OK.

129
00:08:44,970 --> 00:08:45,290
OK.

130
00:08:45,300 --> 00:08:46,660
So what's going on here.

131
00:08:46,700 --> 00:08:52,070
What did they do to actually come out with these values to the screen in this math class.

132
00:08:52,110 --> 00:09:01,050
As you can see first of all I actually used the implementations that are inside the superclass of these

133
00:09:01,420 --> 00:09:01,960
chat class.

134
00:09:01,960 --> 00:09:04,190
OK so the superclass of this class class is animal.

135
00:09:04,230 --> 00:09:04,820
OK.

136
00:09:05,070 --> 00:09:11,010
I actually use the implementations that are inside the three inch Meffert that is inside these Animal

137
00:09:11,010 --> 00:09:11,320
class.

138
00:09:11,330 --> 00:09:12,010
OK.

139
00:09:12,240 --> 00:09:14,640
The superclass of this class is Animal class.

140
00:09:14,700 --> 00:09:15,330
OK.

141
00:09:15,330 --> 00:09:20,200
So here we actually use the implementations of that Smurfette inside the superclass.

142
00:09:20,490 --> 00:09:29,580
And here we actually use this D-plus operator in order to concatenate these two string values here.

143
00:09:29,580 --> 00:09:30,250
OK.

144
00:09:30,360 --> 00:09:35,630
So this piece of code here actually returns a value of type strange.

145
00:09:35,760 --> 00:09:41,510
OK so we can actually say that this piece of code is our streambed value.

146
00:09:41,660 --> 00:09:42,360
OK.

147
00:09:42,810 --> 00:09:50,790
And here we actually put a plus operator here in order to concatenate this value with another string

148
00:09:50,820 --> 00:09:51,190
value.

149
00:09:51,210 --> 00:09:51,630
OK.

150
00:09:51,720 --> 00:09:57,470
So again this string value here provides us with another string value.

151
00:09:57,500 --> 00:10:04,590
Ok 3 in that format as you can see here first we actually specified the formatting instructions of this

152
00:10:05,010 --> 00:10:10,880
method and then we actually put some arguments that are related to these tokens.

153
00:10:10,890 --> 00:10:11,470
OK.

154
00:10:11,670 --> 00:10:14,260
Number of legs and can hunt other animals.

