Question: I need help with java coding assignment. Please help me. Thanks. Assignment #9 Generic Collections Goal: Learn how to use various Java Generic Collections APIs

I need help with java coding assignment. Please help me. Thanks.

I need help with java coding assignment. Please help me. Thanks. Assignment#9 Generic Collections Goal: Learn how to use various Java Generic Collections

APIs Tasks Read contact information from the attached input file contacts.txt andstore it to various data structures using java Collection classes, then storeback to a file following the directions below. Element of each datastructure must be stored as an object of class Contact that hasthe following four String type instance variables public class Contact implements Comparable{ private String socialSecurityNumber; private String firstName; private String lastName; private StringphoneNumber; Store contacts to an ArrayList, then write the contacts to filecontactsArrayList.txt iterating the ArrayList Create class LastNameComparator that implements Comparator to sortcontacts by last name. Use class LastNameComparator to sort ArrayList using Collections.sort.Then write the contacts to file contactsArrayListOrderByLastName.txt. Store contacts to a LinkedList,

Assignment #9 Generic Collections Goal: Learn how to use various Java Generic Collections APIs Tasks Read contact information from the attached input file contacts.txt and store it to various data structures using java Collection classes, then store back to a file following the directions below. Element of each data structure must be stored as an object of class Contact that has the following four String type instance variables public class Contact implements Comparable { private String socialSecurityNumber; private String firstName; private String lastName; private String phoneNumber; Store contacts to an ArrayList, then write the contacts to file contactsArrayList.txt iterating the ArrayList Create class LastNameComparator that implements Comparator to sort contacts by last name. Use class LastNameComparator to sort ArrayList using Collections.sort. Then write the contacts to file contactsArrayListOrderByLastName.txt. Store contacts to a LinkedList, then write the contacts to file contactsLinkedList.txt iterating the LinkedList Store contacts to a PriorityQueue using method offer, then write the contacts to file contactsPriorityQueue.txt reading each contact using poll Store contacts to a HashSet, then write the contacts to file contactsHashSet.txt iterating the HashSet Store contacts to a TreeSet, then write the contacts to file contactsTreeSet.txt iterating the TreeSet. Use class LastNameComparator to store contacts in the order of last name with TreeSet. Then write the contacts to file contactsTreeSetOrderByLastName.txt. Store contacts to a HashMap using a social security number as a key and a Contact object as a value. Then write the contacts to file contactsHashMap.txt iterating the HashMap 1. 2. 3. 4. 5. 6. 7. 8. Your class must implement interface Comparable for class Contact to provide natural order for TreeSet and PriorityQueue. Please use social security number as a sort key for natural order. To create LastNameComparator, you can refer to Fig 16.8 TimeComparator in the textbook. Your class also must override public boolean equals(Object object) method and public int hashCode() to support HashSet Apply the programming-in-the general approach by using an interface wherever possible The output must be exactly the same as the attached files. For file I/O, please use try-with resources statements

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!