Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:03,650 --> 00:00:05,210
When uncommented is code.
2
00:00:12,550 --> 00:00:15,010
And we can add user input by picking up the make.
3
00:00:24,400 --> 00:00:25,810
And here, I'll pick up the budget.
4
00:00:42,700 --> 00:00:43,660
All right, NetSol.
5
00:00:50,350 --> 00:00:54,460
Task to task is to rewrite the search action, so change the return type to end.
6
00:00:57,290 --> 00:00:59,730
And if it finds a car that the user can afford.
7
00:00:59,750 --> 00:01:05,060
In other words, if this condition is true, then we need to return the index of that car.
8
00:01:14,820 --> 00:01:19,950
Returning the index is going to help us identify which car we're going to sell them and we need to print
9
00:01:19,950 --> 00:01:21,110
the following message.
10
00:01:29,110 --> 00:01:30,070
Paste it over here.
11
00:01:34,240 --> 00:01:35,440
Remove the comments.
12
00:01:41,760 --> 00:01:42,960
Fix it into a string.
13
00:01:47,540 --> 00:01:48,800
There, I'll put the string.
14
00:02:01,020 --> 00:02:04,830
And here I need to connect the two string the description of the car we just found.
15
00:02:23,070 --> 00:02:25,040
And I'll need to fix this one up as well.
16
00:02:50,240 --> 00:02:54,680
All right, if at this point in the code, the function didn't break from the return keyword, it means
17
00:02:54,680 --> 00:03:00,260
it couldn't find a car, in which case the instructions tell us to return a 404.
18
00:03:11,520 --> 00:03:12,900
And print this message.
19
00:03:33,320 --> 00:03:34,730
OK, that's over with.
20
00:03:40,350 --> 00:03:42,270
The next task is to call the action.
21
00:03:44,470 --> 00:03:46,120
Dealership, search car.
22
00:03:50,630 --> 00:03:56,120
The return value is an index, so an index is going to equal the result from searching for a car.
23
00:03:58,330 --> 00:04:03,580
All right, task force, if we can't find what the user is looking for, it's going to prompt the user
24
00:04:03,580 --> 00:04:08,110
to browse through their collection so we can use a switch or NFL statement.
25
00:04:08,110 --> 00:04:10,090
I'll use which to compare the index.
26
00:04:15,520 --> 00:04:17,260
Against the case of Faurot for.
27
00:04:21,209 --> 00:04:25,260
In which case, we're going to print the message asking the user to browse through the collection.
28
00:04:44,350 --> 00:04:48,490
And you can display the entire collection of cars by simply printing the dealership.
29
00:04:50,600 --> 00:04:54,170
Don't forget that the break you at after each case and a switch statements.
30
00:04:59,690 --> 00:05:00,710
Let's run the code.
31
00:05:16,960 --> 00:05:21,130
I'm going to look for a Mercedes, and if I put a budget of a thousand.
32
00:05:28,670 --> 00:05:32,540
It's not going to find anything because our cheapest Mercedes is 12000.
33
00:05:33,910 --> 00:05:36,970
Then it prompts the user to search through the selection of Cartes.
34
00:05:43,200 --> 00:05:45,990
All right, in the event that it does find a car.
35
00:05:51,130 --> 00:05:52,630
Otherwise, a default.
36
00:05:55,060 --> 00:06:01,540
If it returned an actual index, then we know that the last thing printed was if you're interested types.
37
00:06:03,040 --> 00:06:08,920
So here, we'll need to pick up the user's response, but remember it next line gets skipped when it's
38
00:06:08,920 --> 00:06:11,990
ahead of the next and next double next, longer next.
39
00:06:12,400 --> 00:06:16,870
So we need to add a throwaway next line right before the real next line.
40
00:06:36,400 --> 00:06:38,170
And if the decision is yes.
41
00:06:51,440 --> 00:06:52,730
We'll sell them the car.
42
00:07:04,070 --> 00:07:04,910
Run the code.
43
00:07:24,160 --> 00:07:27,250
I want to buy a Mercedes, my budget is twenty thousand.
44
00:07:31,810 --> 00:07:34,900
Hi, found me a Mercedes for 12000, what a deal.
45
00:07:36,160 --> 00:07:37,660
I am going to buy this car.
46
00:07:41,530 --> 00:07:43,310
And our code works beautifully.
47
00:07:44,080 --> 00:07:49,030
Before we move to the next task, I want to add a line of spacing right here so I would need to go to
48
00:07:49,030 --> 00:07:49,930
the drive method.
49
00:07:52,710 --> 00:07:53,730
And add a new line.
50
00:07:56,890 --> 00:07:57,820
We on the code.
51
00:08:15,880 --> 00:08:18,790
I'll look for a Honda with a budget of fourteen thousand.
52
00:08:20,460 --> 00:08:23,280
And nice, another very good deal from the Java dealership.
53
00:08:24,610 --> 00:08:25,920
And this looks a lot better.
54
00:08:40,700 --> 00:08:46,610
The last task is to ignore lighter cases, because if you rerun the code, if I rate lower case Nissan
55
00:08:46,610 --> 00:08:47,870
instead of upper case.
56
00:08:51,220 --> 00:08:54,670
It's not going to find what I'm looking for because we're storing it as an uppercase.
57
00:09:00,620 --> 00:09:05,390
So I need to use the equals ignore case method for it to ignore letter cases when it's comparing the
58
00:09:05,390 --> 00:09:06,200
two strings.
59
00:09:11,570 --> 00:09:16,430
I'll need to do the same thing here in case the user writes uppercase, yes, this comparison should
60
00:09:16,430 --> 00:09:17,120
still be true.
61
00:09:19,750 --> 00:09:20,680
And let's try to.
62
00:09:31,310 --> 00:09:34,490
All right, Nissan and I'll butcher every letter case.
63
00:09:38,210 --> 00:09:41,300
And then all right, yes, using purely uppercase, yes.
64
00:09:43,890 --> 00:09:46,180
And our application is fully complete.
65
00:09:46,860 --> 00:09:49,020
We built a fully functional application.
66
00:09:53,080 --> 00:09:58,690
And notice how clean and expressive the code is, it's almost like I'm reading English here, the dealership
67
00:09:58,690 --> 00:09:59,680
has five cars.
68
00:09:59,890 --> 00:10:03,610
It asks the user the type of car they're looking for and what they can afford.
69
00:10:03,940 --> 00:10:10,090
The dealership is going to, quote, unquote, search for a car according to the information provided.
70
00:10:10,870 --> 00:10:16,480
And in the case of a 404, if they can't find anything, the user can browse through the dealership.
71
00:10:19,060 --> 00:10:26,740
And if it does find something, the dealership sells them a car, this is almost plain English, anybody
72
00:10:26,740 --> 00:10:30,670
can read your code in Maine and quickly understand what your application does.
73
00:10:33,570 --> 00:10:39,480
And that is why object oriented programming, programming, using objects results in higher quality
74
00:10:39,480 --> 00:10:39,930
code.
6879
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.