Java

TOPIC 21 – MAPS

 

LESSON WORK

 

 

QUESTION 1

Is the following scenario a good use of a map?  Why or why not?  Is there a change that you could do to make it work?

 

SITUATION 1

In the famous Marvel organization called Shield, every member has a security clearance.  Captain America is level 9.  Nick Fury is level 11.  Basic operatives are level 5.  We could use a map with names as keys and security clearance levels as values.

 

SITUATION 2

You are creating an RPG video game.  Sorcerers in the game have an assortment of spells.  Each spell has its own damage amount.  We could store the damage amount as the key and the spell names as the value.

 

SITUTATION 3

In scrabble, each word is worth a different amount of points.  We could store the words as keys and their point amount as the value.

 

QUESTION 2

 

Create a map data structure.  Add pairs to it.  Try removing pairs.  Test the structure fully.