Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions