The final task for part five is to create a function named manage movies.
It's going to be void.
We'll start by creating a new object of the scanner class.
This scanner object is going to receive input from the system system Dothan and the Java dock tells
us to create an infinite loop.
So we'll do that.
And we need to ask the user if they want to purchase rent return.
So you can just copy the snippet from the article.
And we'll start by picking up the user's response.
String response is equal to scanned.
Next line.
And first, we'll check if the response isn't equal to A, B or C.
Then we're going to close, scatter and break the loop.
If it's one of them, then we're going to ask them to name the movie they want to purchase rent or return.
Well pick up the response with scanned our next line.
And what we do with this movie depends on the user's previous response.
So we're going to make a switch statement that compares the users response against three cases.
Case A.
Casspi.
In Casey.
If it's they just sell them the movie story don't action name sell.
If it's case B, then we're going to rent them the movie.
And if it's Casey, let them return the movie.
And at the end, whatever their option was, we're going to print updated movies.
Followed by all the movies inside the store object.
And that's all.
Now we just got a call, this method from Maine.
First at our other movies to the collection.
Great to begin.
See them all here.
I'm going to start by purchasing a movie.
And you know what?
I want to make sure this happened in one line.
Kay.
Whenever we run the code.
I'll purchase The Dark Knight.
And it sells me The Dark Knight.
And you can tell it's been removed from the store.
Now I'm going to rent Pulp Fiction.
Then I'll return Pulp Fiction.
And this works perfectly.
Now I can just type anything to exit the loop.
And that's all.
We finished building our application.
The next step is to make a bulletproof, and we're going to do that in part six.
I will see you in there.