1
00:00:00,140 --> 00:00:06,330
So at the first instance variable is going to be of type string and the name of this instance variable

2
00:00:06,420 --> 00:00:12,530
is computer computer name semicolon.

3
00:00:12,860 --> 00:00:15,310
And then let me show you the emulator here.

4
00:00:15,560 --> 00:00:18,530
So the first one is computer name as you can see here.

5
00:00:18,800 --> 00:00:23,500
And then we need to actually create another instance variable which is for computer power.

6
00:00:23,540 --> 00:00:31,210
So this instance variable is going to be our third integer computer power semicolon.

7
00:00:31,850 --> 00:00:34,080
And here we have computer speed.

8
00:00:34,100 --> 00:00:41,810
So here I can say ain't computer speed semicolon.

9
00:00:42,350 --> 00:00:46,600
And make sure to also declare them and declare them as private.

10
00:00:46,730 --> 00:00:50,780
So use this private access modifier for this instance variables.

11
00:00:51,290 --> 00:00:59,390
So private stream computer name private int a computer power private in a computer speed and an instance

12
00:00:59,390 --> 00:01:01,980
variable is for this one computer run.

13
00:01:02,060 --> 00:01:09,830
So here I can say private in computer ram semi-colon.

14
00:01:10,220 --> 00:01:12,870
And the next one is computer screen.

15
00:01:12,920 --> 00:01:14,990
So private

16
00:01:19,080 --> 00:01:25,270
strange computer screen semi-colon.

17
00:01:25,680 --> 00:01:28,040
The next one is keyboard computer keyboard.

18
00:01:28,050 --> 00:01:40,760
So private strange computer keyboard semicolon and the next one is computer CPQ.

19
00:01:40,980 --> 00:01:51,390
So here I can say again private strange computer CPQ semicolon.

20
00:01:51,750 --> 00:01:54,260
So now we have this instance variables.

21
00:01:54,330 --> 00:01:59,270
So let's actually create an empty constructor for this class because we need it.

22
00:01:59,340 --> 00:02:06,090
If you want to actually use it inside of an activity class because of you want to store our values to

23
00:02:06,090 --> 00:02:12,120
these instance variables and we want to actually just send these values to the firebase.

24
00:02:12,130 --> 00:02:16,390
So let's actually create an empty constructor so public.

25
00:02:16,890 --> 00:02:20,660
And again the name of the constructor must be the same as the name of the class.

26
00:02:20,910 --> 00:02:22,600
Public computer.

27
00:02:22,980 --> 00:02:27,820
And then here I just need to put up a pair of Prentice's here.

28
00:02:28,000 --> 00:02:29,830
I should be an empty parenthesis.

29
00:02:30,000 --> 00:02:33,600
And then I need to open and close this constructed by using these curly braces.

30
00:02:33,600 --> 00:02:35,760
So this is going to be an empty constructor.

31
00:02:35,790 --> 00:02:36,350
Right.

32
00:02:36,750 --> 00:02:44,250
And now let's actually create another constructor so that we can actually initialize our instance variables

33
00:02:44,250 --> 00:02:45,760
inside our constructor.

34
00:02:45,780 --> 00:02:53,430
So here inside this class inside this computer class just right click here and then click on generate

35
00:02:54,330 --> 00:03:01,890
and then click on constructor and here select all these instance variables just press the shift key

36
00:03:01,890 --> 00:03:08,470
on your keyboard and just select all these instance variables and then click on OK.

37
00:03:08,640 --> 00:03:15,180
So now as you can see we have actually a constructor here that is created automatically by yantra studio

38
00:03:15,180 --> 00:03:15,990
for us.

39
00:03:15,990 --> 00:03:21,210
So let me actually create a newline character here so that you can see these values here.

40
00:03:21,240 --> 00:03:25,920
So we have actually a constructor and this construction accepts some arguments.

41
00:03:25,920 --> 00:03:28,580
The first one is computer name which is of type string.

42
00:03:28,830 --> 00:03:32,760
The second argument is actually of the integer and is computer power.

43
00:03:32,760 --> 00:03:36,680
The first argument is computer speed which is an integer.

44
00:03:36,990 --> 00:03:43,720
And we have this computer RAM which is of type integer computer screen screen and computer keyboards

45
00:03:43,810 --> 00:03:44,170
training.

46
00:03:44,190 --> 00:03:47,560
And finally we have this computer Sibiu which is of type string.

47
00:03:47,730 --> 00:03:52,370
And inside the curly braces of this constructed as you can see here we are actually initialising which

48
00:03:52,650 --> 00:03:54,180
are instance variables.

49
00:03:54,270 --> 00:03:58,500
So this computer name refers to this computer name here right.

50
00:03:58,500 --> 00:04:03,920
Assignment operator computer name this computer power assignment operator computer power.

51
00:04:04,230 --> 00:04:08,790
And here T-stat computer speed assignment operator computer speed.

52
00:04:08,790 --> 00:04:15,310
So he had this current data computer the refers to these computers here that we have and this that computer

53
00:04:15,310 --> 00:04:18,480
ram time assignment operator computer ram as you can see here.

54
00:04:18,480 --> 00:04:25,020
This computer screen assignment operator computer screen this that computer keyboard assignment operator

55
00:04:25,020 --> 00:04:26,970
computer keyboard as you can see.

56
00:04:26,970 --> 00:04:30,590
And these computers Sibiu you assignment operator computer spew.

57
00:04:30,900 --> 00:04:38,430
So here this keyword actually refers to an instance that we are going to create from this computer class.

58
00:04:38,460 --> 00:04:38,750
Right.

59
00:04:38,760 --> 00:04:46,040
When I say these computer name refers to an instance of this class that actually has this computer in

60
00:04:46,040 --> 00:04:47,320
an instance variable.

61
00:04:47,400 --> 00:04:50,570
So that's why it is called instance variable right.

62
00:04:50,580 --> 00:04:57,060
So this computer name is actually adding to the instance variable assignment operator computer name

63
00:04:57,210 --> 00:04:59,320
refers to this argument.

64
00:04:59,400 --> 00:05:00,370
Right.

65
00:05:00,390 --> 00:05:02,470
So hopefully that makes sense.

66
00:05:02,530 --> 00:05:09,630
And now this actually creates the getters and they get this that we need for these instance variables.

67
00:05:09,630 --> 00:05:17,340
So again before the end in calibrates of this class and inside this class just right click here and

68
00:05:17,340 --> 00:05:21,580
then we can generate and he can get it right.

69
00:05:21,750 --> 00:05:24,810
And he had against select all these instance variables.

70
00:05:24,810 --> 00:05:30,390
So just hold the shift key on your keyboard and select all these instance variables and then click on

71
00:05:30,420 --> 00:05:31,070
OK.

72
00:05:31,370 --> 00:05:36,690
So now as you can see here all these getters are actually the generators for us automatically by the

73
00:05:36,690 --> 00:05:37,860
Android studio.

74
00:05:37,920 --> 00:05:38,550
Right.

75
00:05:38,550 --> 00:05:42,550
So we have actually get help for the computer name public screen.

76
00:05:42,780 --> 00:05:45,370
Gates can actually see you.

77
00:05:45,600 --> 00:05:50,480
So as you can see here the order is not actually important here.

78
00:05:50,610 --> 00:05:53,240
So the first Gittel is for the computer Sibiu.

79
00:05:53,310 --> 00:06:00,360
So publics can get computers is actually a method that is going to return the value of the compute computer

80
00:06:00,390 --> 00:06:02,250
Sibiu instance variable.

81
00:06:02,640 --> 00:06:07,980
And here we have public street get a computer name that is going to return the value of the computer

82
00:06:07,980 --> 00:06:12,410
name public end gets computer power.

83
00:06:12,420 --> 00:06:19,080
As you can see here returned computer power public integrates computer speed written computer speed

84
00:06:19,410 --> 00:06:27,300
public interface computer ram written computer ram public street kids computer screen right hand computer

85
00:06:27,300 --> 00:06:27,820
screen.

86
00:06:27,930 --> 00:06:34,070
And finally we have this method public is three jet's computer keyboard written computer keyboard.

87
00:06:34,140 --> 00:06:36,510
So this is our computer class right.

88
00:06:36,510 --> 00:06:44,190
So let's go back to our main activity the job right here and now let's actually just declare some objects

89
00:06:44,190 --> 00:06:44,510
here.

90
00:06:44,520 --> 00:06:50,790
The first object that we need to declare here is actually firebase database and the name of our Optik

91
00:06:50,790 --> 00:06:53,410
is going to be firebase database semi-colon.

92
00:06:53,700 --> 00:06:59,430
And the second object is of type database reference and the name of this object is database reference.

93
00:06:59,430 --> 00:07:00,110
Right.

94
00:07:00,300 --> 00:07:06,690
So this Firebrace database here is going to actually help us to actually get the firebase instance.

95
00:07:06,690 --> 00:07:09,030
So let me show you the other browser.

96
00:07:09,030 --> 00:07:15,770
So as you can see here this is our web browser and this is actually a database instance right.

97
00:07:15,810 --> 00:07:22,230
So now as you can see here we have this instance and we have this database reference that can actually

98
00:07:22,230 --> 00:07:24,250
help us to find the reference.

99
00:07:24,330 --> 00:07:32,190
And actually we can actually work on our references and we can add references and work on our database.

100
00:07:32,310 --> 00:07:34,410
So let's go back to our Android studio.

101
00:07:34,410 --> 00:07:36,940
So the first object is firebase database.

102
00:07:37,110 --> 00:07:39,500
And the second object is database reference.

103
00:07:39,540 --> 00:07:44,730
So here inside is uncreate Mefford Let's actually initialize these objects that we declared here in

104
00:07:44,730 --> 00:07:46,890
line number 28 and 29.

105
00:07:47,190 --> 00:07:49,280
So the first object is firebase database.

106
00:07:49,350 --> 00:07:54,510
Inside this uncreate my feet I can say firebase database assignment operator.

107
00:07:54,720 --> 00:07:59,310
And here I can say firebase database that gets instance semicolon.

108
00:07:59,850 --> 00:08:05,520
In fact let's actually change the name of this variable which is of type firebase database.

109
00:08:05,520 --> 00:08:10,640
So here inside this class as you can see in line number 28 we actually created this value right.

110
00:08:10,650 --> 00:08:12,170
We declared this variable.

111
00:08:12,540 --> 00:08:14,810
And we named it firebase database.

112
00:08:14,820 --> 00:08:19,330
So let's actually just name it firebase database instance right.

113
00:08:19,410 --> 00:08:24,090
It's more meaningful firebase database instance and inside is uncreate unfaith.

114
00:08:24,260 --> 00:08:27,680
There's actually just type in firebase database instance.

115
00:08:27,690 --> 00:08:33,930
So now I have to firebase database instance right by calling this method we get the firebase database

116
00:08:33,930 --> 00:08:34,620
instance.

117
00:08:34,890 --> 00:08:41,580
And now let's say actually initialize this database reference here.

118
00:08:41,580 --> 00:08:47,390
So now here after this line of code I can't say databased or France assignment operator.

119
00:08:47,520 --> 00:08:53,220
And then I need to refer to the name of this instance firebase database instance so Firebrace database

120
00:08:53,280 --> 00:08:57,780
instance it get the reference as you can see here.

121
00:08:57,870 --> 00:09:00,890
Choose this one with this argument which is of type string.

122
00:09:01,260 --> 00:09:04,120
And now I need to provide an argument of types 3.

123
00:09:04,150 --> 00:09:11,470
So inside Apprentice's just put two double quotes and you want to get to instance to computers category.

124
00:09:11,850 --> 00:09:16,620
So here all you want to actually create reference to our computer.

125
00:09:16,620 --> 00:09:19,290
The computers category so I want to create.

126
00:09:19,290 --> 00:09:20,120
So let's go back.

127
00:09:20,220 --> 00:09:22,120
Let's go to our web browser here.

128
00:09:22,140 --> 00:09:29,220
So as you can see here when I say unable to actually just create a category here I can just click on

129
00:09:29,220 --> 00:09:36,870
this child here and here I can say for example computers light computers and because I want to create

130
00:09:36,870 --> 00:09:41,430
a category we do not actually provide a value for this value here.

131
00:09:41,430 --> 00:09:42,060
Right.

132
00:09:42,090 --> 00:09:48,810
So we just again click on these I tried here and now as you can see these computers is actually a category

133
00:09:48,810 --> 00:09:51,420
that can contain other types.

134
00:09:51,480 --> 00:09:52,160
Right.

135
00:09:52,170 --> 00:09:54,880
So that's what you want to do with the code.

136
00:09:54,960 --> 00:09:59,970
So let's go back to what Android studio when I actually just referred to this database reference here

137
00:10:00,450 --> 00:10:03,300
I am actually just referring to this instance.

138
00:10:03,300 --> 00:10:03,730
Right.

139
00:10:03,780 --> 00:10:10,070
So this instance firebase database instance is has the inside has the database instance right.

140
00:10:10,180 --> 00:10:15,400
These firebase database instance already has the database instance.

141
00:10:15,630 --> 00:10:18,040
So what do I mean by database instance.

142
00:10:18,090 --> 00:10:22,550
This means that we already have access to this instance.

143
00:10:22,680 --> 00:10:23,610
As you can see here.

144
00:10:23,910 --> 00:10:30,050
But now because I want to actually create a category by using Java codes as you can see here in line

145
00:10:30,060 --> 00:10:38,580
number 58 I just referred to the name of this database reference so that we can actually just hold the

146
00:10:38,580 --> 00:10:44,940
database reference inside this variable and then I put an assignment operator here and then I'll refer

147
00:10:45,000 --> 00:10:52,050
to the name of this firebase database instance and then I want to actually create a reference to our

148
00:10:52,050 --> 00:10:56,970
category and then after this we can actually add children to this category.

149
00:10:57,120 --> 00:11:00,500
So firebase database instance that reference computers.

150
00:11:00,540 --> 00:11:05,890
So this line of code here is like this one here as you can see we created a category computer.

151
00:11:06,060 --> 00:11:12,570
And now this database defense has a reference to the computers category inside our database.

152
00:11:12,570 --> 00:11:14,480
Not this one but this one.

153
00:11:14,640 --> 00:11:17,040
So let's you delete this one here.

154
00:11:17,070 --> 00:11:19,170
Let's go back to our Android studio and what.

155
00:11:19,180 --> 00:11:21,390
Now I want to show you that how this works.

156
00:11:21,390 --> 00:11:25,960
So here for example I can say database reference dots tied.

157
00:11:26,220 --> 00:11:34,350
And now I can actually provide the child so the child could be for example key and he or dot set value

158
00:11:34,620 --> 00:11:39,420
and the value could be for example value added with a semicolon at the end of my statement.

159
00:11:39,420 --> 00:11:39,930
Right.

160
00:11:40,020 --> 00:11:46,440
So now let's run our project and now let me show you the web browser and the emulator

161
00:11:48,960 --> 00:11:54,140
so as you can see here now we have these computers category as you can see here.

162
00:11:54,420 --> 00:12:00,390
And inside these computers tactically we have these key and value so that that's how you can actually

163
00:12:00,390 --> 00:12:05,310
create a category by using your double quotes by you writing double quotes.

164
00:12:05,310 --> 00:12:08,340
You can also create categories and children here.

165
00:12:08,640 --> 00:12:09,750
So that's how you do it.

166
00:12:09,810 --> 00:12:15,330
So now in line number six the list actually deletes this line of code here and now you know that we

167
00:12:15,420 --> 00:12:18,780
have actually our reference to these computers category.

168
00:12:18,780 --> 00:12:25,500
So if I had on my project nothing happens let's actually go back to our Web browser and see if we actually

169
00:12:25,500 --> 00:12:29,530
did it this instance here this category.

170
00:12:29,640 --> 00:12:34,230
As you can see here now that I am actually running this project as as you can see here nothing happens.

171
00:12:34,230 --> 00:12:34,880
Why.

172
00:12:34,890 --> 00:12:39,820
Because it in line number 58 inside and inside our Android studio.

173
00:12:39,880 --> 00:12:46,230
You're saying that we are going to have a category that is actually computers but but because we haven't

174
00:12:46,230 --> 00:12:50,810
still provided tights for this category the database is not going to show us.

175
00:12:50,880 --> 00:12:55,400
So that for us because this chatter doesn't have children.

176
00:12:55,410 --> 00:13:01,680
So first we need to provide the children and then we can see these computers category inside our database.

177
00:13:01,800 --> 00:13:02,450
As you can see here.

178
00:13:02,460 --> 00:13:05,750
But for now nothing just happens here.

179
00:13:05,820 --> 00:13:07,380
So let's go back to what I understood you.

180
00:13:07,470 --> 00:13:12,820
So now you know that this database of friends has a reference to the computers category.

181
00:13:12,840 --> 00:13:13,950
So now.

