Task 1: Implement printJobs()
When trying out the program, and later when reading the code, you
hopefully noticed that there’s some work to do in the
method. As it stands, it currently just prints a message:
"printJobs is not implemented yet".
Complete this method. It should print out jobs in this precise format:
For the autograding script to correctly grade your code, you’ll need to match this format exactly. In particular, note the number of asterisks surrounding each listing, and the blank line between listings.
If there are no results, it should print
No Results in the following format:
Search term: Example Search Term with No Results No Results View jobs by (type 'x' to quit): 0 - Search 1 - List
Again, you should use this exact message.
To do this, you’ll need to iterate over an
ArrayList of jobs. Each job is itself a
HashMap. While you can get each of the items out of
HashMap using the known keys (
location, etc.), think instead about creating a nested loop to loop over each
HashMap. If a new field is added to the job records, this approach will print out the new field without any updates to
Test this method before moving on to your next step:
- Save your changes.
- Select Run from the Run menu and choose to run the
TechJobsclass (or if you have recently run it, just select the green arrow in the top right corner of the screen).
- Select “1” to list the jobs, and then “0” to list them all.
- Make sure the printout matches the styling above.
- Test that it prints a descriptive message if no jobs are found by selecting “0” to search and then “3” to search for a location. Then enter a location that is not in the data (e.g. “Cancun”). Your message should be displayed.