When uncommented is code.
And we can add user input by picking up the make.
And here, I'll pick up the budget.
All right, NetSol.
Task to task is to rewrite the search action, so change the return type to end.
And if it finds a car that the user can afford.
In other words, if this condition is true, then we need to return the index of that car.
Returning the index is going to help us identify which car we're going to sell them and we need to print
the following message.
Paste it over here.
Remove the comments.
Fix it into a string.
There, I'll put the string.
And here I need to connect the two string the description of the car we just found.
And I'll need to fix this one up as well.
All right, if at this point in the code, the function didn't break from the return keyword, it means
it couldn't find a car, in which case the instructions tell us to return a 404.
And print this message.
OK, that's over with.
The next task is to call the action.
Dealership, search car.
The return value is an index, so an index is going to equal the result from searching for a car.
All right, task force, if we can't find what the user is looking for, it's going to prompt the user
to browse through their collection so we can use a switch or NFL statement.
I'll use which to compare the index.
Against the case of Faurot for.
In which case, we're going to print the message asking the user to browse through the collection.
And you can display the entire collection of cars by simply printing the dealership.
Don't forget that the break you at after each case and a switch statements.
Let's run the code.
I'm going to look for a Mercedes, and if I put a budget of a thousand.
It's not going to find anything because our cheapest Mercedes is 12000.
Then it prompts the user to search through the selection of Cartes.
All right, in the event that it does find a car.
Otherwise, a default.
If it returned an actual index, then we know that the last thing printed was if you're interested types.
So here, we'll need to pick up the user's response, but remember it next line gets skipped when it's
ahead of the next and next double next, longer next.
So we need to add a throwaway next line right before the real next line.
And if the decision is yes.
We'll sell them the car.
Run the code.
I want to buy a Mercedes, my budget is twenty thousand.
Hi, found me a Mercedes for 12000, what a deal.
I am going to buy this car.
And our code works beautifully.
Before we move to the next task, I want to add a line of spacing right here so I would need to go to
the drive method.
And add a new line.
We on the code.
I'll look for a Honda with a budget of fourteen thousand.
And nice, another very good deal from the Java dealership.
And this looks a lot better.
The last task is to ignore lighter cases, because if you rerun the code, if I rate lower case Nissan
instead of upper case.
It's not going to find what I'm looking for because we're storing it as an uppercase.
So I need to use the equals ignore case method for it to ignore letter cases when it's comparing the
two strings.
I'll need to do the same thing here in case the user writes uppercase, yes, this comparison should
still be true.
And let's try to.
All right, Nissan and I'll butcher every letter case.
And then all right, yes, using purely uppercase, yes.
And our application is fully complete.
We built a fully functional application.
And notice how clean and expressive the code is, it's almost like I'm reading English here, the dealership
has five cars.
It asks the user the type of car they're looking for and what they can afford.
The dealership is going to, quote, unquote, search for a car according to the information provided.
And in the case of a 404, if they can't find anything, the user can browse through the dealership.
And if it does find something, the dealership sells them a car, this is almost plain English, anybody
can read your code in Maine and quickly understand what your application does.
And that is why object oriented programming, programming, using objects results in higher quality
code.