package com.codegym.task.task08.task0816;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/*
Kind Emma and the summer holidays

*/

public class Solution {
    public static HashMap<String, Date> createMap() throws ParseException {
        DateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
        HashMap<String, Date> map = new HashMap<String, Date>();
        map.put("Stallone", df.parse("JUNE 1 1980"));
        map.put("Federer", df.parse("AUGUST 8 1981"));
        map.put("Lenin", df.parse("SEPTEMBER 2 1990"));
        map.put("Johnson", df.parse("AUGUST 31 1890"));
        map.put("Nadal", df.parse("JUNE 3 1986"));
        map.put("Peterson", df.parse("JULY 15 2000"));
        map.put("Clarke", df.parse("DECEMBER 1 1969"));
        map.put("Lemonade", df.parse("JANUARY 31 2019"));
        map.put("Mr.Snake", df.parse("APRIL 20 1960"));
        map.put("VODKA", df.parse("MAY 31 2009"));
        //write your code here
        return map;
    }

    public static void removeAllSummerPeople(HashMap<String, Date> map) {
        //write your code here
        Calendar c = Calendar.getInstance();

        Iterator<Map.Entry<String, Date>> itr = map.entrySet().iterator();
        while(itr.hasNext()){
            Map.Entry<String, Date> entry = itr.next();
            c.setTime(entry.getValue());
            if(c.get(Calendar.MONTH) == 5 || c.get(Calendar.MONTH) == 6 || c.get(Calendar.MONTH) == 7){
                itr.remove();
            }
        }
    }

    public static void main(String[] args) {
        HashMap<String, Date> map = new HashMap<String, Date>();
        map = createMap();// value in createMap() function is not getting assigned in the HashMap variable map.
    }
}