Collection Class Exercise


Use eclipse for this exercise.

  1. Copy all files from Files, Collections Exercise folder.
  2. Add an equals method to the Person class which returns true if the first and last names match.
  3. 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.
  4. Create a Collection of Person objects in main.
  5. 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.
  6. Add a loop to main to do the following:
    1. Prompt the user and read the first and last name.
    2. Get the person from the Collection.
    3. 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.
  7. Write the method (called in your loop) to read in the info, create the new Person, and add it to the Collection.
  8. 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