Let's not create constant exporting classes the classes that exist only for defining constants. 2
For example we have Jondrette fill in book and movie classes and it has a range of values in each of 3
those domains. 4
So instead of defining these values in databases we can also define them in a constant exploding class 5
. 6
Similarly range of values for gender field in use class cannot be defined using constant exporting class 7
and we can do the same for user type feel within the user class. 8
These classes will be useful when we have to check if the field has a particular value. 9
For example if we want to check if a particular book belongs to a certain genre then the constant exporting 10
class corresponding to this feature will be useful. 11
We will see this when we later implement east kid friendly eligible method. 12
So these classes are useful. 13
And let's go ahead and create them. 14
Let's first create a new package for constants 15
. 16
So it's semantics were really are constants. 17
Let's create a constant exporting class called user type 18
since it's going to expose only the constants. 19
So there are no instance variables are there are no methods in this class. 20
So it's just going to be static final peak of Feels so that it's compile time constants so we don't 21
need to create an instance of this class so we can define a private constructor. 22
Now let's define the constants 23
since it's a compile time constant we need to use all caps. 24
That's the convention we know that it's got it as user. 25
Now let's simply copy this. 26
So let's call the second one as student editor 27
and Thirty-One chief editor. 28
Okay so that's a user type class. 29
Let's create one for gender 30
in the private constructor 31
and the gender field is here. 32
So let's go ahead and create three constants 33
. 34
Initialize it with zero 35
to two on 36
transgender. 37
Make it two. 38
So that's the gender class. 39
And we also need to do more for the genre for book genre and movie joinery and I'm just going to create 40
them off line as darling dear and that's much better. 41
It will say for some time. 42
So let me just create it off line and I'll come back and show it to you. 43
OK. 44
Here's a book John reckless and these are all the constants that it has. 45
And it's in the Constans package. 46
And here is a movie class and it has a lot of constants as you can see here the different genres classics 47
drama comedy and so on. 48
I'm going to upload the book movie genre and book Journey to the resources section so you can just download 49
them and that's it. 50
So those are the four constant exporting classes that we have created. 51
And that's a