package Hashmap;


public class MyHashMap {
	
	int key;
	String value;
	
	// Ein Array von MyHashMap-Objekten erstellen
    String table[];
    final int SIZE  =10;

    // Konstruktor, der das Array initialisiert
    public MyHashMap() {
        table = new String[SIZE];  //Array mit 10 MyHashMap-Objekten erstellen
        this.key = 0;
        this.value = null;
    }
    
    
    private int Hashadresse(int key) {
    	return key % table.length;
    }

	public void put(int key, String value) {
	int index = Hashadresse(key);
	table[index] = value;
		
    }
	
	public void getValue(int key) {
		int index = Hashadresse(key);
		System.out.println(table[index]);
	}
	
	public void printHashMap() {
		for (int i = 0; i < table.length; i++) {
			System.out.println("[" + i + "]" + " : " + table[i]);
		}
	}

	public boolean isEmpty(int key) {
		int index = Hashadresse(key);
		
		if (table[index] == null)
			return true;
		
		return false;
	}
	
	public static void main(String[] args) {
		MyHashMap m1 = new MyHashMap();
		m1.put(14, "Schrank");
		m1.put(12, "Sofa");
		m1.put(8, "TV");
		m1.printHashMap();
		m1.getValue(14);
		
		System.out.println(m1.isEmpty(9));
		
		Character key = 'a';
		int hash = key.hashCode();
		System.out.println(hash);
		
	
	}
}
