/* package whatever; // don't place package name! */

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


 class StateCityClassTest {

    public static void main(String[] args) {
        StateCityMap map = new StateCityMap();

        map.putStateCity(1253, "São Paulo", "Osasco");
        map.putStateCity(1254, "São Paulo", "Santos");
        map.putStateCity(1255, "Rio de Janeiro", "Cabo Frio");

        System.out.println(map.getStateCity(1253));

        System.out.println(map.showAllItens());

    }

}

class StateCityMap {

    private final Map<Integer, HashMap<String, String>> codeStateList;

    public StateCityMap() {
        codeStateList = new HashMap<>();
    }

    public void putStateCity(int code, String state, String city) {
        HashMap<String, String> stateCity = new HashMap<>();
        stateCity.put(state, city);
        codeStateList.put(code, stateCity);
    }

    public String getStateCity(int key) {
        return this.containsKey(key) ? codeStateList.get(key).toString() : null;
    }

    public void removeStateCity(int key) {
        for (Iterator<Map.Entry<Integer, HashMap<String, String>>> iterator = codeStateList.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry<Integer, HashMap<String, String>> entry = iterator.next();
            if (entry.getKey().equals(key)) {
                iterator.remove();
            }
        }
    }

    public boolean containsKey(int key) {
        return codeStateList.containsKey(key);
    }

    
    public String showAllItens() {
        String allItens = "";
        for (Map.Entry<Integer, HashMap<String, String>> entry : codeStateList.entrySet()) {
            allItens += entry.getKey() + " : " + entry.getValue() + "\n";
        }
        return allItens;
    }
}
