package com.codegym.task.task08.task0815;

import java.util.HashMap;
import java.util.HashSet;

/*
Census
The getSameLastNameCount() method must return the number of people whose last name is the same as the lastName parameter.
*/

public class Solution {
    public static HashMap<String, String> createMap() {

        HashMap<String, String> map = new HashMap<String, String>();

        map.put("A","E1");
        map.put("Ab","E2");
        map.put("Abc","E3");
        map.put("Abcd","E4");
        map.put("Abcde","E6");
        map.put("Abcdef","E5");
        map.put("Abcdefg","E8");
        map.put("Abcdefgh","E9");
        map.put("Abcdefghj","E10");
        map.put("Abcdefghjk","E11");


        return map;


    }

    public static int getSameFirstNameCount(HashMap<String, String> map, String Name) {

        int count =0;

        for (HashMap.Entry <String,String>pair:map.entrySet()) {

            if(pair.getKey().equals(Name))count++;

        }

        return count;


    }

    public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {

        int count =0;

        for (HashMap.Entry <String,String>pair:map.entrySet()) {

             if(pair.getKey().equals(lastName))count++;

        }

             return count;


    }

    public static void main(String[] args) {

    }
}