Question
2. Create a SenatorTest class to test the following functionality in its main method. a. Declare and initialize an empty Queue of Senator objects named
2. Create a SenatorTest class to test the following functionality in its main method. a. Declare and initialize an empty Queue of Senator objects named senatorQueue. b. Declare and initialize an empty HashMap named senatorMap. The keys will be the names of the senators and the entries in the map will be the corresponding senator objects. c. Use the BufferedReader class to read the data.txt file. The contents of the file are shown below. Create the data.txt file in HW5_lastName. d. Read the contents of the text file one line at a time using a loop. The program should work for any number of input lines. In this loop, 1. Invoke the processInputData method for each line read. This method returns the corresponding Senator object. 2. Add this Senator object to the senatorQueue. 3. Insert this Senator object into the senatorMap using the senators name as the key. e. After the loop is processed, do the following. 1. Iterate over the senatorQueue and display each element to the console. 2. Access the keys of the senatorMap and assign them to an appropriate variable. Create an iterator over the keys. Iterate over each key in this set and display the associated object in the map to the console.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started