Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,050 --> 00:00:04,620
The goal of this workbook is the quality control, the car and dealership classes.
2
00:00:08,130 --> 00:00:09,810
Because if you're on the out the way it is.
3
00:00:18,750 --> 00:00:24,720
Both cars have negative price values and blank values, and these values don't make any sense and the
4
00:00:24,720 --> 00:00:26,550
color should be forbidden from passing them.
5
00:00:28,800 --> 00:00:33,420
So in the car constructor going to throw an illegal argument exception if the price is less than zero.
6
00:00:36,440 --> 00:00:38,810
Throw a new illegal argument, exception.
7
00:00:46,180 --> 00:00:48,160
Price cannot be less than zero.
8
00:00:55,520 --> 00:01:00,950
We're going to throw another exception if the make is no blank, if you make is equal to no or if the
9
00:01:00,950 --> 00:01:02,060
make is blank.
10
00:01:05,960 --> 00:01:06,860
Throw new.
11
00:01:11,800 --> 00:01:13,300
A legal argument, exception.
12
00:01:14,880 --> 00:01:17,280
Make cannot be null or blank.
13
00:01:27,810 --> 00:01:29,250
And if you rerun the code.
14
00:01:36,130 --> 00:01:41,200
The first checkpoint crashes the app, the price cannot be less than zero, so we need to pass a valid
15
00:01:41,200 --> 00:01:42,760
price values into the constructor.
16
00:01:52,040 --> 00:01:56,420
And the second checkpoint crashes, the app make cannot be null or blank.
17
00:01:59,550 --> 00:02:03,690
Pass valid, make values into the constructor, I'm going to put Nissan and Toyota.
18
00:02:11,310 --> 00:02:16,050
And by this point, the caller has been forced to pass incorrect values into the constructor.
19
00:02:16,680 --> 00:02:21,600
And so if you rerun the code, the second car's value still doesn't make any sense.
20
00:02:22,230 --> 00:02:25,710
The center is another place where quality control needs to take place.
21
00:02:30,440 --> 00:02:34,580
So inside set make I'm going to throw another illegal argument, exception, if the caller passes and
22
00:02:34,580 --> 00:02:36,110
make that is blank or null.
23
00:02:44,430 --> 00:02:45,270
There are new.
24
00:02:46,780 --> 00:02:48,280
A legal argument, exception.
25
00:02:52,460 --> 00:02:54,470
Make cannot be null or blank.
26
00:03:06,390 --> 00:03:13,380
Rerun the code and now the checkpoint and set may crash the app, it forces the color you to pass a
27
00:03:13,380 --> 00:03:16,650
valid make value to the set, make setar the stooges that.
28
00:03:27,490 --> 00:03:31,930
OK, good, but clearly the price setter is another place that needs quality control.
29
00:03:35,940 --> 00:03:39,480
So inside set price, I'm going to say if price is less than zero.
30
00:03:41,730 --> 00:03:44,130
Then I'll throw a new illegal argument exception.
31
00:03:46,950 --> 00:03:49,050
Price cannot be less than zero.
32
00:04:00,370 --> 00:04:01,390
Rerun the code.
33
00:04:05,560 --> 00:04:07,930
And now the checkpoint and set price crashes.
34
00:04:07,960 --> 00:04:12,520
The app, it forces the caller to pass a valid price value to the set price setter.
35
00:04:18,660 --> 00:04:19,709
I run the code again.
36
00:04:21,019 --> 00:04:22,010
And beautiful.
37
00:04:25,490 --> 00:04:29,840
Now we need to investigate the dealership class, so inside the class, there is no need to throw a
38
00:04:29,840 --> 00:04:31,320
legal argument, exceptions anywhere.
39
00:04:31,790 --> 00:04:36,950
Worst thing that could happen is someone could pass on a knowledge of the instructor, but the app would
40
00:04:36,950 --> 00:04:38,810
already throw a null pointer exception.
41
00:04:39,390 --> 00:04:41,090
The same can be said for said car.
42
00:04:44,170 --> 00:04:46,690
But what if the caller passes an invalid index here?
43
00:04:48,010 --> 00:04:53,140
Well, the code would already throw an array index out of bounds exception, so you throwing another
44
00:04:53,140 --> 00:04:55,240
unchecked exception wouldn't make any sense.
45
00:04:57,320 --> 00:04:59,390
What about an illegal state exception?
46
00:04:59,960 --> 00:05:04,640
Well, let me ask you this, does that make sense for a dealership to call the sale method if there
47
00:05:04,640 --> 00:05:05,750
are no cars inside?
48
00:05:06,140 --> 00:05:07,310
Absolutely not.
49
00:05:07,880 --> 00:05:11,990
So if the dealership is empty, then it's not in a valid state to call the sale method.
50
00:05:13,200 --> 00:05:16,110
So what I'm going to do is create a separate method called exempting.
51
00:05:25,470 --> 00:05:27,270
And it's going to loop through the array.
52
00:05:31,030 --> 00:05:33,790
And if any of the objects is not known.
53
00:05:38,720 --> 00:05:41,080
Then you're going to return false and break the loop.
54
00:05:42,640 --> 00:05:46,930
Otherwise, if they all end up being null, then the dealership is empty and will return true.
55
00:05:48,390 --> 00:05:53,850
And now back here, I can say if this if the current object that's calling this method is empty.
56
00:06:03,130 --> 00:06:04,990
Then throw an illegal state exception.
57
00:06:10,200 --> 00:06:12,500
Canacol sell when dealership is empty.
58
00:06:20,530 --> 00:06:26,220
And that's all you had to checkpoints to the car dealership classes, and now each checkpoint forces
59
00:06:26,230 --> 00:06:29,410
the caller to invoke the methods and constructors properly.
5609
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.