Collection Class Exercise
Use eclipse for this exercise.
- Copy all files from Files, Collections Exercise folder.
- Add an equals method to the Person class which returns true
if the first and last names match.
- Add a toString method to the Person class. Make sure your Person
is nicely formatted. Use multiple lines and indentation in the String
you return.
- Create a Collection of Person objects in main.
- Prompt the user for the input file name, create a Scanner for
the file, and call the build method to read Person objects
into the Collection.
- Add a loop to main to do the following:
- Prompt the user and read the first and last name.
- Get the person from the Collection.
- If the Person is in the Collection, print it. If not,
print a not found message and ask the user if they would like
to add the Person. If so, call a method to prompt for the
Person info and add the Person to the Collection.
Ask the user when they want to exit from the loop.
- Write the method (called in your loop) to read in the info,
create the new Person,
and add it to the Collection.
- Run your program using the person.dat file and make sure it works
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2017