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