/*
 * @topic T01725 Map, HashMap, TreeMap, Map.Entry
 * @brief Main driver
 */
package wk12assoccontainers;

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class MainApp {
    public static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Map<String,Integer> word2number =
                new TreeMap<String,Integer>();

        // Populate map with some values:
        word2number.put("one",1);
        word2number.put("two",2);
        word2number.put("three",3);
        word2number.put("four",4);
        word2number.put("five",5);
        
        for(;;) {
            // use the map
            String input = Validator.getString( sc, "enter one/two/three ");
            if ( input.equalsIgnoreCase("quit")) {
                break;
            }
            if ( word2number.containsKey(input) ) {
                int value  = word2number.get(input);
                System.out.println("The value is ["+ value + "]");
            } else {
                System.out.println("Sorry, [" + input + "] not found" );
            }
        }
        // print the contents of the map
        System.out.println("Map contains:");
        for( Map.Entry<String, Integer> entry : word2number.entrySet() ) {
            String myKey = entry.getKey();
            int myValue = entry.getValue();
            System.out.println(myKey + " = " + myValue );
            
        }
        
    }//main

}//class MainApp