Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level08.lesson08.task04;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map;
- /* Удалить всех людей, родившихся летом
- Создать словарь (Map<String, Date>) и занести в него десять записей по принципу: «фамилия» - «дата рождения».
- Удалить из словаря всех людей, родившихся летом.
- */
- public class Solution
- {
- public static HashMap<String, Date> createMap()
- {
- HashMap<String, Date> map = new HashMap<String, Date>();
- map.put("Сталлоне", new Date("JUNE 1 1980"));
- map.put("Пахан", new Date("JUNE 27 1983"));
- map.put("Stanis", new Date("JUNE 30 1984"));
- map.put("Shalabay", new Date("APRIL 16 1984"));
- map.put("Batya", new Date("DECEMBER 17 1959"));
- map.put("Pechifon", new Date("MARCH 04 1984"));
- map.put("Shalabay1", new Date("APRIL 16 1984"));
- map.put("Shalabay2", new Date("APRIL 16 1984"));
- map.put("Shalabay3", new Date("APRIL 16 1984"));
- map.put("Shalabay4", new Date("APRIL 16 1984"));
- //Напишите тут ваш код
- return map;
- }
- public static void removeAllSummerPeople(HashMap<String, Date> map)
- {
- //Напишите тут ваш код
- Iterator<Map.Entry<String, Date>> iterator = map.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry<String,Date> pair = iterator.next();
- if (pair.getValue().getMonth()>4&&pair.getValue().getMonth()<8) {
- iterator.remove();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement