1
00:00:00,300 --> 00:00:05,340
In this solution, we're quality control the store class, we need to forbid the caller from misusing

2
00:00:05,340 --> 00:00:09,150
the methods or the constructor, the constructor doesn't receive any parameters.

3
00:00:09,150 --> 00:00:10,540
So there's nothing to check here.

4
00:00:11,070 --> 00:00:16,230
There is nothing to quality control in the setar, because if the caller happens to pass a no instead

5
00:00:16,230 --> 00:00:20,280
of an actual object, the code would already throw a nail pointer exception.

6
00:00:20,580 --> 00:00:23,290
So throwing our own exception would be redundant.

7
00:00:23,820 --> 00:00:25,740
The same thing can be said for ad movie.

8
00:00:27,570 --> 00:00:32,759
However, there's a lot to quality control in the action, first of all, if the store object doesn't

9
00:00:32,759 --> 00:00:36,410
have any movies, then it's not an illegal state to call the method.

10
00:00:36,720 --> 00:00:40,250
You can't return, sell or rent a movie that doesn't exist.

11
00:00:40,740 --> 00:00:44,190
So here, we'll say if movies, that is empty.

12
00:00:46,660 --> 00:00:47,830
We'll throw a new.

13
00:00:50,810 --> 00:00:52,550
Illegal state exception.

14
00:00:53,470 --> 00:00:56,530
Store not in a valid state to perform action.

15
00:01:05,640 --> 00:01:10,980
One more thing we want to check is that the action they want to perform can only be one of three things

16
00:01:10,980 --> 00:01:12,770
sell, rent or return.

17
00:01:13,380 --> 00:01:16,670
So if the caller passes anything else, we need to throw an exception.

18
00:01:17,130 --> 00:01:20,010
So if the auction they pass, if it doesn't equal sell.

19
00:01:27,650 --> 00:01:29,420
Or if it doesn't equal rent.

20
00:01:33,950 --> 00:01:35,630
Or if it doesn't equal return.

21
00:01:46,420 --> 00:01:49,540
Then we'll throw a new illegal argument exception.

22
00:01:52,010 --> 00:01:55,100
Action must be sell, rent or return.

23
00:02:02,280 --> 00:02:07,080
All right, and the color shouldn't be allowed to pass a name that's blank, so if the name is equal

24
00:02:07,080 --> 00:02:07,650
to No.

25
00:02:12,180 --> 00:02:13,890
Or the name is equal to blank.

26
00:02:16,920 --> 00:02:19,440
We'll throw a new illegal argument exception.

27
00:02:21,240 --> 00:02:23,250
Name Kaname Neller Black.

28
00:02:29,640 --> 00:02:34,410
And the last thing we're going to do is forbid the caller from trying to sell a movie that has already

29
00:02:34,410 --> 00:02:35,100
been rented.

30
00:02:37,350 --> 00:02:41,670
So inside, so we're going to check if the movie at the index.

31
00:02:49,810 --> 00:02:51,750
That was a request that is not available.

32
00:02:58,450 --> 00:03:03,220
Then we're going to throw a new illegal state exception, because the state of the movie object that

33
00:03:03,220 --> 00:03:06,650
we're trying to sell is inappropriate for this operation.

34
00:03:07,150 --> 00:03:10,380
We'll just say cannot sell a movie that was rented out.

35
00:03:13,380 --> 00:03:18,330
And that's all the quality control we need to apply and now this method is going to forbid the caller

36
00:03:18,330 --> 00:03:23,190
from misusing it, if the caller does misuse it, their application is going to crash and they're going

37
00:03:23,190 --> 00:03:24,420
to have to fix their code.

