Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

contacts.txt file includes: 614-22-4216 Arnold Bennett 703-4430-2393 821-32-4320 William Black 919-302-5942 951-53-5667 Wilfred Owen 202-343-5948 395-76-3098 Jandy Nelson 201-952-1029 678-45-3920 Sarah Kane 405-591-0819 396-40-2059 Jan

image text in transcribedimage text in transcribed

contacts.txt file includes:

614-22-4216 Arnold Bennett 703-4430-2393 821-32-4320 William Black 919-302-5942 951-53-5667 Wilfred Owen 202-343-5948 395-76-3098 Jandy Nelson 201-952-1029 678-45-3920 Sarah Kane 405-591-0819 396-40-2059 Jan Karon 706-212-6940 529-54-2401 Miranda Jarrett 902-988-3092 654-23-1250 Brenda Jackson 812-123-8763 392-0511-2345 Abby Gaines 233-820-2383 392-0511-2345 Alicia Scott 723-555-5457

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 . . . . 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: 3

blur-text-image

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

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

=+j Identify the challenges of training an international workforce.

Answered: 1 week ago