Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /*
- Добрая Зинаида и летние каникулы
- */
- public class test {
- public static HashMap<String, Date> createMap() throws Exception {
- HashMap<String, Date> map = new HashMap<String, Date>();
- SimpleDateFormat format = new SimpleDateFormat("MMMM dd yyyy", Locale.ENGLISH);
- map.put("Stallone", format.parse("JUNE 01 1980")); //напишите тут ваш код
- map.put("S1", format.parse("JANUARY 01 1980"));
- map.put("S2", format.parse("MARCH 05 1980"));
- map.put("S3", format.parse("APRIL 10 1980"));
- map.put("S4", format.parse("JULY 11 1980"));
- map.put("S5", format.parse("JUNE 07 1980"));
- map.put("S6", format.parse("SEPTEMBER 11 1980"));
- map.put("S7", format.parse("MAY 17 1980"));
- map.put("S8", format.parse("AUGUST 11 1980"));
- map.put("S9", format.parse("MAY 01 1980"));
- return map;
- }
- public static void removeAllSummerPeople(HashMap<String, Date> map) {
- //напишите тут ваш код
- ArrayList<String> delete = new ArrayList<>();
- for(Map.Entry<String,Date> pair:map.entrySet()){
- if(pair.getValue().getMonth() > 4 && pair.getValue().getMonth() < 8){
- delete.add(pair.getKey());
- }
- }
- for(String object : delete) {
- map.remove(object);
- }
- }
- public static void main(String[] args) throws Exception{
- //Это для тестов программы и проверки ее работы, после удалить все из метода мэйн
- HashMap<String, Date> map = createMap();
- removeAllSummerPeople(map);
- for(Map.Entry<String,Date> pair:map.entrySet()){
- System.out.println(pair.getKey() + " " + pair.getValue());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement