In part one, we implemented tasks one to four, and now the final task is to let the user search the
database by name.
So first it asks the user, who do you want information on?
And the reason I'm using print, not print line, is because I want the user to enter the information
beside the question, in which case I'm going to say string name is equal to scan next line to pick
up the user's search query.
Now we have the user's answer so I can make a for loop that runs through every row in the database.
We are going to start at Rosero and the loop is going to keep running until we index every row in the
database.
And we know that the name is stored in the first index of each row.
So I'm going to check the first index in each row.
And check if it equals the user's response name.
Then we're going to print all of the information about the figure that the user is searching for.
I'll print a tab of space first, will print the user's name.
Which is that index zero of rowby.
Then I'll print the date of birth.
Which is that index one of Roee?
Then I'll print occupation, which is not indexed to overthrow I, and with this final line of code,
we are done, the most exciting part is to test your code.
Once again, I'm going to add information about Marco Polo.
And Shakespeare.
Prints all of the information good, and now it's asking me to search for a specific figure that I want
information on, I'm going to say I want information on Marco Polo.
And here it's running through every row in the database, and if what the user is searching for matches
a name in the database, it's going to print all of their own values, as you're seeing here.
Now, it would be nice if there was a line of space between here and here, so we can do just that.
I'll put a new line and we're not going to put a new line here because we need the scanner input to
be on the same line.
So it makes sense that a new line right after.
I can rerun the code and faster the output, and it looks like Java PD's complete.
That is all I want to congratulate you on finishing up Module one at this point in the course, you've
learned and implemented all of the Java fundamentals.
You know how to store values inside variables, control how your code around using effluents, which
break your code up into functions, run your code in a loop and use arrays to store many values at once.
Now that you've reached the end, it's time for the ultimate challenge.
You're going to try and build tic tac toe.
This is not an easy challenge and you can bet your cup of Java that it's going to involve tuti arrays
and nested loops.
I hope you're excited.
Let's do it.