Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the most common types of buffers?

Answered: 1 week ago