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 printJobs
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:
*****
position type: Data Scientist / Business Intelligence
name: Sr. IT Analyst (Data/BI)
employer: Bull Moose Industries
location: Saint Louis
core competency: Statistical Analysis
*****
*****
position type: Web - Back End
name: Ruby specialist
employer: LaunchCode
location: Saint Louis
core competency: Javascript
*****
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:
No Results
Be sure to use the exact message No Results
taking care to match casing. In full context with prompting, the application will look like this when a user enters a term that would yield no results:
Search term:
Example Search Term with No Results
No Results
View jobs by (type 'x' to quit):
0 - Search
1 - List
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
the HashMap
using the known keys (employer
, 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 printJobs
.
Test this method before moving on to your next step:
- Save your changes.
- Select Run from the Run menu and choose to run the
TechJobs
class (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.