1
00:00:00,530 --> 00:00:06,630
Watch everyone now in this tutorial we're going to actually go ahead and continue building our fourth

2
00:00:06,740 --> 00:00:08,300
Android application.

3
00:00:08,660 --> 00:00:13,130
So as you can see here here we actually see some errors.

4
00:00:13,160 --> 00:00:15,560
Ok the Android studio is complaining.

5
00:00:15,830 --> 00:00:22,430
And we need to actually first fix these errors in order to actually run our application.

6
00:00:22,430 --> 00:00:25,330
So let's actually fix this our first error here.

7
00:00:25,340 --> 00:00:32,340
As you can see here let's actually hover our mouse pointer over this error area and see what's the error.

8
00:00:32,360 --> 00:00:39,220
As you can see here it says there is no default constructor available income.

9
00:00:39,230 --> 00:00:43,560
That example that maters I saw that that app for that animal.

10
00:00:43,640 --> 00:00:44,200
OK.

11
00:00:44,330 --> 00:00:46,640
It refers to this animal class here.

12
00:00:46,670 --> 00:00:47,340
OK.

13
00:00:47,570 --> 00:00:53,840
So it says that there is no default constructor here and it's right because we actually created a custom

14
00:00:53,840 --> 00:00:59,000
constructor in this class as you can see here this is Arkan's custom constructor.

15
00:00:59,000 --> 00:00:59,550
OK.

16
00:00:59,810 --> 00:01:04,110
So then we actually create a constructor in our class.

17
00:01:04,220 --> 00:01:08,560
The compiler doesn't provide a default constructor for us.

18
00:01:08,570 --> 00:01:09,350
OK.

19
00:01:09,920 --> 00:01:17,570
So when you actually create a cost a constructor in the Animal class need to actually implicitly or

20
00:01:17,660 --> 00:01:22,180
explicitly call the constructor of the superclass.

21
00:01:22,250 --> 00:01:27,230
OK so now we are inside the scope of this animal class here.

22
00:01:27,230 --> 00:01:28,000
OK.

23
00:01:28,400 --> 00:01:32,750
And this animal class extends from the Object class.

24
00:01:32,870 --> 00:01:40,850
And this means that this animal class inherits all of the features and behaviors that are inside of

25
00:01:41,060 --> 00:01:44,040
this object class into this Animal class.

26
00:01:44,060 --> 00:01:44,710
OK.

27
00:01:45,080 --> 00:01:49,300
So this class inherits all of that features that are inside this object class.

28
00:01:49,310 --> 00:01:50,010
OK.

29
00:01:50,510 --> 00:01:56,380
So out the inside the object class which is a predefined class in Java.

30
00:01:56,510 --> 00:01:58,100
We've got our constructor.

31
00:01:58,100 --> 00:02:02,650
So let's actually go inside the object class and see and find that constructor OK.

32
00:02:02,900 --> 00:02:08,560
So I need to actually hold the command key and then click on this object here.

33
00:02:08,810 --> 00:02:14,090
And if you are using a Windows machine you need to actually hold the control key and then click on the

34
00:02:14,090 --> 00:02:14,490
object.

35
00:02:14,510 --> 00:02:15,140
OK.

36
00:02:15,320 --> 00:02:19,300
So as you can see here this is the constructor inside this object class.

37
00:02:19,320 --> 00:02:19,910
OK.

38
00:02:20,270 --> 00:02:25,110
And this comment says constructs a new instance of Object.

39
00:02:25,130 --> 00:02:25,680
OK.

40
00:02:25,820 --> 00:02:32,860
So as you can see here this is the constructor and this constructor doesn't actually accept any arguments.

41
00:02:33,140 --> 00:02:37,320
And as you can see here there is no implementation inside this constructor OK.

42
00:02:37,910 --> 00:02:41,130
So let's go back inside the Animal class as you can see here.

43
00:02:41,540 --> 00:02:47,590
Here we need to actually implicitly or explicitly call the constructor of the superclass because you

44
00:02:47,590 --> 00:02:53,780
are actually inheriting all of the features of this object class into the Animal class.

45
00:02:53,780 --> 00:02:59,030
The compiler does provide a default constructor for us.

46
00:02:59,120 --> 00:03:00,150
OK.

47
00:03:00,470 --> 00:03:04,300
The default constructor that is inside of this object class.

48
00:03:04,430 --> 00:03:10,860
Remember that a default constructor is a constructor without no parameters.

49
00:03:10,880 --> 00:03:11,590
OK.

50
00:03:11,930 --> 00:03:16,050
And the constructor that is inside this object class has no promotors.

51
00:03:16,100 --> 00:03:16,920
OK.

52
00:03:17,090 --> 00:03:22,820
So inside this Animal class because we are inheriting all of the features of this object class into

53
00:03:22,820 --> 00:03:28,310
this Animal class the compiler does provide a default constructor for us.

54
00:03:28,310 --> 00:03:34,440
OK so we don't need to actually explicitly initialize initialize the constructor of the superclass.

55
00:03:34,510 --> 00:03:36,520
OK so the superclass is object.

56
00:03:36,530 --> 00:03:37,110
OK.

57
00:03:37,280 --> 00:03:43,160
And inside the Animal class we don't need to explicitly initialize that constructor that is inside this

58
00:03:43,430 --> 00:03:44,130
object class.

59
00:03:44,140 --> 00:03:52,070
OK the compiler does provide a default constructor for us but inside this cat class as you can see here

60
00:03:52,070 --> 00:03:54,100
there is another story here.

61
00:03:54,150 --> 00:04:00,830
Here in this class in the scope of this class we are actually extending all of the features that are

62
00:04:00,890 --> 00:04:05,690
inside of this animal class into this chat class.

63
00:04:05,720 --> 00:04:06,460
OK.

64
00:04:06,890 --> 00:04:14,560
We are inheriting all of the features and behaviors that are declared as public entities Kathe class.

65
00:04:14,660 --> 00:04:15,150
OK.

66
00:04:15,200 --> 00:04:23,130
So inside this Animal class let's actually hold the command key and then click on animal here.

67
00:04:23,240 --> 00:04:24,530
As you can see this is an Animal class.

68
00:04:24,540 --> 00:04:25,060
OK.

69
00:04:25,340 --> 00:04:28,820
Inside this class I have a custom constructor here.

70
00:04:29,000 --> 00:04:32,920
I created my own constructor for this animal class.

71
00:04:32,930 --> 00:04:40,820
So inside this chat class we need to actually initialize the constructed of the superclass So the constructor

72
00:04:40,820 --> 00:04:44,360
of the superclass is this constructor OK.

73
00:04:44,690 --> 00:04:51,110
So inside the constructor of this Chadha class we need to initialize the constructor of the superclass

74
00:04:51,170 --> 00:04:57,080
otherwise the compiler is going to actually complain and we would not be able to run our application.

75
00:04:57,080 --> 00:05:04,160
So in order to initialize the constructor of the superclass which is this animal class I just need to

76
00:05:04,160 --> 00:05:06,040
type in here super.

77
00:05:06,500 --> 00:05:07,310
OK.

78
00:05:07,670 --> 00:05:10,230
And then inside the apprentice's as you can see here.

79
00:05:10,280 --> 00:05:12,610
I need to actually passing some values.

80
00:05:12,860 --> 00:05:13,410
OK.

81
00:05:13,430 --> 00:05:18,230
Let's actually hover our mouse pointer over this error area and see what's the error.

82
00:05:18,230 --> 00:05:25,660
It asks us to actually passing some values for the next instance variable and a value for.

83
00:05:25,700 --> 00:05:32,030
For the color instance variable of value for the amount of spit instance variable and of value for the

84
00:05:32,090 --> 00:05:34,190
amount of power or instance variable.

85
00:05:34,310 --> 00:05:38,620
Ok you may wonder that Verity's or instance variables come from.

86
00:05:38,720 --> 00:05:42,350
We don't have these instance variables in this chat class.

87
00:05:42,350 --> 00:05:50,190
So why do this construct and asks us to actually Pessin our values for these instance variables.

88
00:05:50,380 --> 00:05:57,840
Because you are actually inheriting all of the features of this animal class into this math class Vini

89
00:05:57,860 --> 00:06:02,100
to actually initialize those instance variables too.

90
00:06:02,300 --> 00:06:07,120
So inside this animal class as you can see here we've got this instance variables here.

91
00:06:07,130 --> 00:06:07,600
OK.

92
00:06:07,630 --> 00:06:13,370
In say the cat class we are actually inheriting all of these instance variables and methods.

93
00:06:13,400 --> 00:06:13,980
OK.

94
00:06:14,300 --> 00:06:18,540
But as you can see here these instance variables are declared as private.

95
00:06:18,560 --> 00:06:25,730
OK this instance variable is honestly part of the child's class instance variables are not visible to

96
00:06:25,730 --> 00:06:26,560
this class.

97
00:06:26,720 --> 00:06:28,560
Ok to this chat class because.

98
00:06:28,760 --> 00:06:33,050
Because this instance variables are declared as private.

99
00:06:33,160 --> 00:06:33,580
OK.

100
00:06:33,620 --> 00:06:41,510
So we need to actually pass some values to this superclass constructor in order to actually fix these

101
00:06:41,510 --> 00:06:41,930
errors.

102
00:06:41,930 --> 00:06:42,410
OK.

103
00:06:42,590 --> 00:06:46,940
So how can we actually initialize those instance variables in this class class.

104
00:06:47,000 --> 00:06:53,110
We need to actually provide some arguments inside the prentices of the constructor of this Kathe class.

105
00:06:53,120 --> 00:06:54,480
Ok so here.

106
00:06:54,800 --> 00:07:00,290
Now I want to actually provide some arguments and then I want to actually assign those arguments to

107
00:07:00,290 --> 00:07:05,080
the instance variables of the superclass which is the animal class.

108
00:07:05,090 --> 00:07:05,700
OK.

109
00:07:05,840 --> 00:07:13,170
First of all I need to provide a value for this strange named instance variable here.

110
00:07:13,190 --> 00:07:13,830
OK.

111
00:07:14,050 --> 00:07:18,440
Of types thrain in order to actually initialize the named instance variable OK.

112
00:07:18,750 --> 00:07:20,210
So the cat class.

113
00:07:20,330 --> 00:07:25,570
First of all I need to actually specify the data type of my argument.

114
00:07:25,580 --> 00:07:26,330
Strange.

115
00:07:26,540 --> 00:07:27,170
OK.

116
00:07:27,500 --> 00:07:29,880
And the name of my argument is name.

117
00:07:29,960 --> 00:07:35,500
Now I need to actually provide another argument for the coloring instance variable as you can see this

118
00:07:35,500 --> 00:07:37,390
is our color instance variable.

119
00:07:37,580 --> 00:07:43,640
So as you can see here we've got this color instance variable but this is an argument for this color

120
00:07:43,670 --> 00:07:44,770
instance variable.

121
00:07:44,780 --> 00:07:51,890
So inside the cat class and inside the Prentice's of this constructor I need to actually provide an

122
00:07:51,890 --> 00:08:03,230
argument for the color instance variable Strunk color comma and then I need to actually provide an other

123
00:08:03,230 --> 00:08:07,810
argument for this amount of speed here.

124
00:08:07,980 --> 00:08:09,970
Amount of speed instance variable here.

125
00:08:10,040 --> 00:08:10,880
OK.

126
00:08:11,210 --> 00:08:18,890
So inside the Kathe class I need to actually create another argument in amount of speed.

127
00:08:19,330 --> 00:08:19,760
OK.

128
00:08:19,810 --> 00:08:20,730
Come on.

129
00:08:21,200 --> 00:08:27,550
And then I need to actually provide another argument for this amount of power instance variable.

130
00:08:27,550 --> 00:08:27,730
OK.

131
00:08:27,740 --> 00:08:33,770
As you can see we've got this amount of power argument here and here we are actually assigning this

132
00:08:33,830 --> 00:08:36,410
argument to this instance variable here.

133
00:08:36,410 --> 00:08:36,970
OK.

134
00:08:37,250 --> 00:08:45,040
So in say the cat class you need to actually create another argument in amount of power.

135
00:08:45,740 --> 00:08:57,140
OK comma so now inside the Prentice's of this super here I can actually pass these arguments here.

136
00:08:57,140 --> 00:09:08,220
OK so name comma color comma amount of speed comma amount of power.

137
00:09:08,660 --> 00:09:09,240
OK.

138
00:09:09,470 --> 00:09:12,250
So as you can see here now the error is gone.

139
00:09:12,440 --> 00:09:12,980
OK.

140
00:09:13,100 --> 00:09:14,960
We don't see any error here.

141
00:09:15,140 --> 00:09:15,640
OK.

142
00:09:15,800 --> 00:09:24,030
Because we actually successfully initialized the constructor of the superclass.

143
00:09:24,050 --> 00:09:24,520
OK.

144
00:09:24,620 --> 00:09:30,290
So as you can see here inside the Animal class this is the constructor of the superclass and this constructor

145
00:09:30,320 --> 00:09:32,910
actually exits for arguments.

146
00:09:33,020 --> 00:09:33,670
OK.

147
00:09:33,890 --> 00:09:40,320
And inside the cat class you are actually passing D's of value for those four arguments here.

148
00:09:40,330 --> 00:09:46,760
OK of value for the name instance valuable value for the color instance variable of value for the amount

149
00:09:46,760 --> 00:09:51,410
of instance variable and a value for the amount of power instance variable.

150
00:09:51,620 --> 00:09:56,750
So here we are actually explicitly calling the constructor of the superclass.

151
00:09:56,770 --> 00:09:57,150
OK.

