1

00:00:00,720  -->  00:00:01,980
Hi there.

2

00:00:02,160  -->  00:00:03,420
Welcome back.

3

00:00:03,600  -->  00:00:08,230
In the last lesson re-implemented east kid friendly eligible method.

4

00:00:08,580  -->  00:00:14,820
And with that we completed part of the functionality for monitoring bookmarks as kid friendly.

5

00:00:14,890  -->  00:00:21,390
Now let's write code that will actually allow editors and chief editors to my bookmarks as kid friendly

6

00:00:21,390  -->  00:00:22,560
.

7

00:00:22,560  -->  00:00:26,120
The new code will make use of easy kid friendly eligible method.

8

00:00:26,160  -->  00:00:32,750
That is if the method returns true for a bookmark only then an editor can approve or reject the bookmark

9

00:00:32,850  -->  00:00:39,360
as kid friendly like in the case of bookmarking process a proof or rejection will be done by a randomisation

10

00:00:40,290  -->  00:00:46,270
Lidderdale will enhance the functionality to make real input from the user from the console.

11

00:00:46,320  -->  00:00:48,050
So let's get started.

12

00:00:48,240  -->  00:00:52,050
Let's begin with the bookmark class and let's introduce a new for you.

13

00:00:52,090  -->  00:00:54,150
Callers get friendly status.

14

00:00:54,780  -->  00:00:59,110
So this field basically tells whether a bookmark is good for me or not.

15

00:00:59,310  -->  00:01:01,070
OK so let's introduce that field.

16

00:01:01,330  -->  00:01:04,400
It would be a string.

17

00:01:06,990  -->  00:01:14,850
So initially it can be initialized with a value called as a known and later when an editor or the chief

18

00:01:14,850  -->  00:01:21,420
editor marks a particular bookmark as either a prude or rejected then the value of this field will be

19

00:01:21,420  -->  00:01:22,140
updated.

20

00:01:22,320  -->  00:01:24,630
OK so basically this field can have three values.

21

00:01:24,630  -->  00:01:28,440
It can be unknown or it can be approved or rejected.

22

00:01:28,530  -->  00:01:34,770
So the right thing to do would be to have a constant exporting class and how all these values within

23

00:01:34,770  -->  00:01:37,230
that class and then reference that.

24

00:01:37,890  -->  00:01:38,940
So one other benefit.

25

00:01:38,970  -->  00:01:44,610
The main benefit of a constant exporting class which I did not explain earlier is that you have a single

26

00:01:44,610  -->  00:01:49,880
place where you have all these constants and you can reference them from anywhere within your code.

27

00:01:50,400  -->  00:01:56,220
So that one day it is if you need to make any change in the value you just updated in only one location

28

00:01:56,220  -->  00:01:56,880
.

29

00:01:57,000  -->  00:02:01,650
Otherwise you would have all these values spread across all your core and if you need to update any

30

00:02:01,650  -->  00:02:08,490
value then you have to change it in one place and also you have to up hand-on every other place where

31

00:02:08,610  -->  00:02:11,230
that value is used and you have to ablated there.

32

00:02:11,490  -->  00:02:17,880
OK so it is very tedious and you may not be able to update in all the locations in some in some cases

33

00:02:17,900  -->  00:02:18,120
.

34

00:02:18,330  -->  00:02:21,300
OK so that's not a good way to do it.

35

00:02:21,330  -->  00:02:26,550
So the right way would be to have such a class and to export all the constants from one place so that

36

00:02:27,150  -->  00:02:30,640
if there is a need to make any change we just make it in only one place.

37

00:02:30,740  -->  00:02:31,290
OK.

38

00:02:31,650  -->  00:02:33,280
So let's just introduce a new class.

39

00:02:33,300  -->  00:02:38,640
In fact I already added this class called it friendly status within the constants which is where we

40

00:02:38,640  -->  00:02:41,180
have all the constant exporting classes.

41

00:02:41,320  -->  00:02:45,460
And since it need not be instantiated it has a pirate constructor.

42

00:02:45,540  -->  00:02:47,380
And here are the three constants.

43

00:02:47,700  -->  00:02:50,770
Which means that they have static and finalizer modifiers.

44

00:02:50,850  -->  00:02:51,710
So one is a brute.

45

00:02:51,720  -->  00:02:54,460
One is rejected and the other one is unknown.

46

00:02:54,600  -->  00:03:00,410
OK so let's just go here and initialiser to unknown

47

00:03:00,440  -->  00:03:07,790
.

48

00:03:08,190  -->  00:03:14,580
Next let's go into the View class view class we know corresponds to the user interface and we have one

49

00:03:14,580  -->  00:03:18,190
method called bookmark which we wrote earlier.

50

00:03:18,450  -->  00:03:22,140
So which corresponds to the bookmarking process.

51

00:03:22,140  -->  00:03:25,050
Now before we get started let's do some refactoring here.

52

00:03:25,050  -->  00:03:31,800
Let's actually create a pneumatic color brawls and let's maybe we will comment on this whole method

53

00:03:31,800  -->  00:03:32,790
book Mont..

54

00:03:33,150  -->  00:03:39,510
And the reason I want to have this new method called browsers because let's try to keep our implementation

55

00:03:39,600  -->  00:03:41,800
as close to reality as possible.

56

00:03:42,180  -->  00:03:48,840
So the browse method will take just the same parameters user and bookmarks and it is kind of like the

57

00:03:48,840  -->  00:03:53,220
user has long been honest browsing all the bookmarks.

58

00:03:53,220  -->  00:03:59,430
So he's presented with all the bookmarks on the user's browsing and his looking at each bookmark and

59

00:03:59,430  -->  00:04:05,430
when he's looking at the bookmark he may perform three actions he may either bookmark a particular item

60

00:04:05,430  -->  00:04:13,470
that he looking at or he in guess if it is an editor or a chief editor then the user can either mark

61

00:04:13,470  -->  00:04:18,600
the bookmark as kid friendly or share the bookmark with a particular with the partner site which is

62

00:04:18,600  -->  00:04:21,750
a feature that we that we are going to add later.

63

00:04:21,750  -->  00:04:26,280
So those are the three actions that a user might take one or more of those actions or the user might

64

00:04:26,280  -->  00:04:30,300
not even do anything with that particular item he may just give the item.

65

00:04:30,300  -->  00:04:32,750
So it is much more realistic that way.

66

00:04:32,760  -->  00:04:38,560
So let's just go ahead and introduce a new matter blows and we will comment this out.

67

00:04:38,670  -->  00:04:39,470
OK.

68

00:04:39,480  -->  00:04:42,680
So let's actually common this OUTFRONT

69

00:04:47,380  -->  00:04:51,400
it's just copy and just simply modify this method.

70

00:04:52,360  -->  00:04:54,910
It's just called it does browse.

71

00:04:56,120  -->  00:04:57,120
OK.

72

00:04:57,190  -->  00:04:59,830
Now a user not get e-mail.

73

00:04:59,830  -->  00:05:02,500
Let's just say he's browsing items

74

00:05:05,290  -->  00:05:07,590
now we will still have the same restriction.

75

00:05:07,590  -->  00:05:12,740
That is a user cannot bookmark more than the user bookmark Lamech.

76

00:05:12,760  -->  00:05:15,780
So it was a file and we still have the same.

77

00:05:16,060  -->  00:05:22,610
So you can think of it as like you're not that there the whole application itself it has a trial version

78

00:05:22,610  -->  00:05:25,950
on within the trial version when the user is using the trial version.

79

00:05:25,950  -->  00:05:31,010
He's not allowed to bookmark more than the bookmark limit number of items.

80

00:05:31,060  -->  00:05:32,980
So you can think of it that way.

81

00:05:33,310  -->  00:05:38,350
So basically what will go the way it's going to be different from the previous version of bookmark is

82

00:05:38,350  -->  00:05:49,210
that this time the user will browse through all the bookmarks and for each bookmark we will use a randomized

83

00:05:49,420  -->  00:05:54,720
randomization to decide whether the user is going to book a bookmark that particular item or not.

84

00:05:54,970  -->  00:06:03,940
So over here the user is actually dating only five times and each time he's just randomly picking a

85

00:06:03,940  -->  00:06:05,120
particular bookmark.

86

00:06:05,380  -->  00:06:11,710
But in the new version the user iterate through all the bookmarks but whether or not to bookmark a particular

87

00:06:11,710  -->  00:06:14,700
item is dependent on the randomization feature.

88

00:06:14,870  -->  00:06:16,310
OK so let's just go ahead and do it.

89

00:06:16,320  -->  00:06:18,280
And I think it should be clear.

90

00:06:18,280  -->  00:06:20,570
So first let's introduce a local variable here.

91

00:06:21,020  -->  00:06:25,880
It's called Does bookmark.

92

00:06:27,440  -->  00:06:30,640
That's how a for loop to iterate.

93

00:06:31,480  -->  00:06:37,060
And let's would be have nested for loop because it's a two dimensional array that we have

94

00:06:53,930  -->  00:06:58,790
now of this bookmark count

95

00:07:02,350  -->  00:07:04,760
is less than it's used.

96

00:07:04,760  -->  00:07:06,000
This

97

00:07:10,630  -->  00:07:13,410
only then the user can bookmark.

98

00:07:14,560  -->  00:07:22,060
Now let's introduce a new method called Get bookmarks decision.

99

00:07:22,900  -->  00:07:27,670
And let's pass this bookmark the current bookmark to this method.

100

00:07:27,710  -->  00:07:28,530
It's a pneumatic.

101

00:07:28,540  -->  00:07:34,090
So we'll just create 3.

102

00:07:34,840  -->  00:07:41,200
Now we need to use a randomization function here let's use it to an earlier operator here.

103

00:07:41,380  -->  00:07:45,760
There's a mad dog around them.

104

00:07:46,300  -->  00:07:55,070
Now of let's say if this value is less than Boinne fine then we will return true which means that user

105

00:07:55,060  -->  00:07:57,490
wants to bookmark that particular item.

106

00:07:57,500  -->  00:08:01,370
Otherwise the user is not interested in it.

107

00:08:01,770  -->  00:08:03,250
OK so let's just say as

108

00:08:08,020  -->  00:08:09,930
how available called Eastbrook Mont.

109

00:08:09,950  -->  00:08:17,860
.

110

00:08:22,600  -->  00:08:25,500
Now it means that the user wants to bookmark.

111

00:08:25,690  -->  00:08:30,730
OK so let's increment this which means that the user is bookmarking a new item

112

00:08:33,620  -->  00:08:42,230
and we can just reuse the scene statement that we can copy both of them here.

113

00:08:44,650  -->  00:08:54,120
Now let's just put the message here because we want to introduce new code later.

114

00:08:56,020  -->  00:08:58,150
So that's it I think there is nothing more here.

115

00:08:58,340  -->  00:09:01,690
So we can just remove all of this

116

00:09:08,520  -->  00:09:13,980
launch.

117

00:09:14,890  -->  00:09:25,270
It's called This as browse and it's since it's not bookmarking alone anymore let's just call it a start

118

00:09:25,270  -->  00:09:26,450
here.

119

00:09:26,570  -->  00:09:30,810
Do the same here.

120

00:09:31,240  -->  00:09:32,610
We can also common this.

121

00:09:32,630  -->  00:09:34,900
I don't think we have to print all of those.

122

00:09:34,900  -->  00:09:39,260
It was just to test whether we were loading the data properly.

123

00:09:39,620  -->  00:09:44,820
So that was during the initial part of writing the code.

124

00:09:45,700  -->  00:09:52,790
Yeah it's Liebert like that it's also common this hard because we have this particular statement which

125

00:09:52,780  -->  00:09:55,430
is saying which user is browsing Diadems.

126

00:09:55,750  -->  00:09:57,920
So we are good with that.

127

00:09:59,090  -->  00:10:05,530
So next let's go ahead and create the new logic for marking as kid friendly

128

00:10:09,350  -->  00:10:15,520
so fasting is it can be done a bookmark can be marked as kid friendly only by either editor or chief

129

00:10:15,530  -->  00:10:16,320
editor.

130

00:10:16,580  -->  00:10:19,400
So let's have that permission first.

131

00:10:21,080  -->  00:10:23,120
We get type.

132

00:10:25,220  -->  00:10:30,510
So if you recall we have this constant exporting class called user type.

133

00:10:31,760  -->  00:10:32,110
OK.

134

00:10:32,120  -->  00:10:33,660
So this is for our editor.

135

00:10:33,680  -->  00:10:35,910
Let's do the same thing our chief editor

136

00:10:39,610  -->  00:10:43,820
is this good user type

137

00:10:43,820  -->  00:10:56,760
.

138

00:10:56,780  -->  00:11:02,330
Next thing is the bookmark itself should be click friendly eligible.

139

00:11:02,420  -->  00:11:05,110
So we have already written them at their ease get friendly eligible.

140

00:11:05,120  -->  00:11:07,390
So let's put another condition here.

141

00:11:07,390  -->  00:11:10,760
Just at the bookmark level.

142

00:11:12,120  -->  00:11:19,160
Literally all of this court I'm sorry it has to be inside the for loop so because we are doing it at

143

00:11:19,670  -->  00:11:21,640
an item level at each item level.

144

00:11:21,640  -->  00:11:23,580
So this is where it has to go.

145

00:11:24,170  -->  00:11:31,400
So as the user is making a decision on whether to bookmark or not then if the user is an editor or chief

146

00:11:31,390  -->  00:11:34,420
editor then makes the next decision here.

147

00:11:34,850  -->  00:11:37,950
OK so he's good friendly energy bill.

148

00:11:38,150  -->  00:11:38,900
OK.

149

00:11:39,230  -->  00:11:40,400
That's one thing.

150

00:11:40,900  -->  00:11:41,450
And

151

00:11:45,680  -->  00:11:52,390
let's go back here and look here and let's put together for this create Gager and center

152

00:11:54,750  -->  00:11:57,380
.

153

00:11:58,150  -->  00:12:01,640
So that's good.

154

00:12:04,460  -->  00:12:05,490
So we want to do this.

155

00:12:05,540  -->  00:12:10,380
Only if the current status is unknown.

156

00:12:10,520  -->  00:12:14,820
OK if it has already been approved or rejected we don't have to do this.

157

00:12:15,020  -->  00:12:20,500
So a user will said the paternally status only if the existing status is unknown.

158

00:12:20,920  -->  00:12:21,430
OK.

159

00:12:21,590  -->  00:12:25,790
So let's not use the kid friendly status constant exporting glass

160

00:12:27,770  -->  00:12:30,120
.

161

00:12:30,890  -->  00:12:31,650
UNKNOWN

162

00:12:40,890  -->  00:12:48,590
OK now let's create a new method called Get geek friendly state as decision just like the baby had this

163

00:12:48,590  -->  00:12:50,200
method get bookmarked position.

164

00:12:50,210  -->  00:12:53,560
Similarly let's also get a map.

165

00:12:53,620  -->  00:12:56,510
Let's also write a method called Get kid friendly state decision

166

00:13:00,850  -->  00:13:02,240
and that's just by our boss.

167

00:13:02,240  -->  00:13:02,870
Bookmark

168

00:13:06,880  -->  00:13:12,720
this one also written Boullion and we would once again use randomisation here.

169

00:13:12,860  -->  00:13:19,880
Actually here it reads a string not boolean.

170

00:13:19,880  -->  00:13:21,520
Now we have three decisions.

171

00:13:21,530  -->  00:13:30,350
One is either a prude and other one is rejected or the third one as user may not want to approve or

172

00:13:30,350  -->  00:13:36,710
reject so uder might still decide to just skip that particular item or not market ask it friendly maybe

173

00:13:36,710  -->  00:13:43,360
he wants to leave it to some other editor or he might want he or she might want to get a decision sometime

174

00:13:43,370  -->  00:13:43,980
later.

175

00:13:44,140  -->  00:13:46,220
So let's have three decisions here.

176

00:13:46,220  -->  00:13:52,730
So first let's say it proved so once again that user Donati operator wine for food is less than wine

177

00:13:52,730  -->  00:13:57,200
for let's recopy this year.

178

00:13:58,280  -->  00:14:00,980
Then the user wants to prove it.

179

00:14:01,630  -->  00:14:09,240
So if that if it is false if it is above point for here better than or equal 2.4 then let's have the

180

00:14:09,240  -->  00:14:13,370
statement.

181

00:14:20,500  -->  00:14:26,870
So the point of this logic is if it is less than one for then use it means that user wants to prove

182

00:14:26,870  -->  00:14:27,360
it.

183

00:14:27,500  -->  00:14:36,340
If it is greater than or equal to less and this has to be 0.4 and if it is less than point eight then

184

00:14:36,350  -->  00:14:40,770
let's say that the user let's say user wants to either reject it.

185

00:14:40,940  -->  00:14:42,950
So we just say you're currently

186

00:14:46,540  -->  00:14:48,330
not rejected.

187

00:14:49,340  -->  00:14:54,980
And if the value is about point eight greater than or equal 2.8 in which case we really would as unknown

188

00:14:54,990  -->  00:14:58,670
.

189

00:15:02,140  -->  00:15:05,060
So we have Nestor Donati operations here

190

00:15:09,100  -->  00:15:10,310
and that's Control shift.

191

00:15:10,320  -->  00:15:12,660
And so that's good.

192

00:15:13,360  -->  00:15:18,910
Let's go back Unidas is a string

193

00:15:22,260  -->  00:15:31,010
.

194

00:15:31,070  -->  00:15:38,840
Now if the status is something other than unknown only then we want to set the status we want to update

195

00:15:38,840  -->  00:15:40,480
the status in the bookmark.

196

00:15:40,580  -->  00:15:42,080
So let's have this condition here

197

00:15:42,090  -->  00:15:49,850
.

198

00:15:54,470  -->  00:16:00,380
So only if it is not equal to unknown then we want to update the status.

199

00:16:00,400  -->  00:16:02,420
So in this case it is a bookmark

200

00:16:06,240  -->  00:16:10,370
that said between the students and let's have a six out statement here

201

00:16:10,380  -->  00:16:17,450
.

202

00:16:25,100  -->  00:16:30,710
So if it is if it is not equal to or known only then we are operating the paternally status and we are

203

00:16:30,710  -->  00:16:35,870
printing the value here of the status value and also the bookmark and just to be clear.

204

00:16:36,230  -->  00:16:37,160
So that's about it.

205

00:16:37,150  -->  00:16:41,430
So let's just go ahead and run this class on launch.

206

00:16:42,200  -->  00:16:43,590
There you go.

207

00:16:44,380  -->  00:16:47,200
So let's just review the output here.

208

00:16:47,890  -->  00:16:51,180
So loading data and then user is browsing items.

209

00:16:51,230  -->  00:16:58,360
So users looking at the first item and he wants to book market which is of eyeblink.

210

00:16:58,730  -->  00:17:04,990
So we are printing only those items which the user wants to bookmark so user is actually browsing all

211

00:17:05,000  -->  00:17:08,020
15 items all 15 bookmarks that we how.

212

00:17:08,240  -->  00:17:15,770
But these are the ones which the user is actually bookmarking So the randomization is telling us that

213

00:17:16,660  -->  00:17:18,300
the user wants to bookmark it.

214

00:17:18,320  -->  00:17:26,880
The randomization process I and I and the user can bookmark at most at most five bookmarks.

215

00:17:26,890  -->  00:17:28,240
So that's the condition we have.

216

00:17:28,280  -->  00:17:29,960
So this is the second user.

217

00:17:30,200  -->  00:17:32,380
And for the third user we have a different output.

218

00:17:32,380  -->  00:17:39,620
That's because this third user is actually an editor of one of the staff members so the user is bookmarking

219

00:17:39,620  -->  00:17:39,670
.

220

00:17:39,670  -->  00:17:46,220
And once this item is bookmarked then the user is also marking the bookmark as kid friendly in this

221

00:17:46,220  -->  00:17:47,460
case it is approved.

222

00:17:47,680  -->  00:17:49,470
And this is the actual bookmark.

223

00:17:49,470  -->  00:17:53,750
The same bookmark has been the same item has been bookmarked also.

224

00:17:53,840  -->  00:18:01,780
So they use it as both bookmarking and is also and is also marking the bookmark as kid friendly.

225

00:18:01,970  -->  00:18:02,570
OK.

226

00:18:02,570  -->  00:18:04,490
Now this is a second one.

227

00:18:04,510  -->  00:18:10,100
And over here the user is doing the same thing and he also does approve.

228

00:18:10,150  -->  00:18:12,110
In this case it is rejected.

229

00:18:12,200  -->  00:18:14,220
The Big Mac has been rejected.

230

00:18:14,370  -->  00:18:19,440
And here is a movie and in this case a movie has been bookmarked.

231

00:18:19,610  -->  00:18:23,910
But they use it as not marking it as kid friendly or anything like that.

232

00:18:24,620  -->  00:18:28,750
And here are some more items which are rejected and which are approved.

233

00:18:29,030  -->  00:18:36,590
So we see this because there is no limit on the items that can be rejected are approved on the items

234

00:18:36,590  -->  00:18:39,570
where the kid friendly status can be marked.

235

00:18:39,620  -->  00:18:46,750
So there is no limit on that like the limit that we how far good for setting up for bookmarking an item

236

00:18:46,760  -->  00:18:47,340
.

237

00:18:47,570  -->  00:18:49,100
So that's it.

238

00:18:49,100  -->  00:18:54,990
So those are the four users performing different actions.

239

00:18:55,040  -->  00:19:00,740
Next we will look at the functionality for sharing of get friendly bookmarks with partner websites
