/*
 * File: SwappingKeysAndValues.java
 * -----------------------
 * An unfinished version of the code that swaps values and keys
 * in a HashMap.
 */

import acm.program.*;

import java.util.*;
import java.io.*;

public class SwappingKeysAndValues extends ConsoleProgram {

	private static final String DICTIONARY = "InterestingDictionary.txt";

	public void run(){
		HashMap<String, String> dict = new HashMap<String, String>();
		
		fillDictionary(dict);
		
		dict = swapKeysAndValues(dict);

		for(String key: dict.keySet()) {
			println(key);
		}

	}
	
	private HashMap<String, String> swapKeysAndValues(HashMap<String, String> dict) {
		// fill this in!
		
		return dict;
	}
	
	private void fillDictionary(HashMap<String, String> dict){
		try {			
			Scanner input = new Scanner(new File(DICTIONARY));
			while(input.hasNextLine()) {
				String word = input.nextLine();
				String definition = input.nextLine();
				dict.put(word, definition);
			}
			input.close();
			
		} catch (IOException ex) {
			println("Couldn't open that dictionary!");
		}
	}


}


