Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
3
Indexable
Never
private static void findOutTheBoundariesbyPlayerInEachVenue(List<Delivery> deliveries, List<Match> matches) {
        Map<String, Map<String,Integer>> theBoundariesByPlayerInEachVenue = new HashMap<>();
        Map<Integer,String> venueMap = new HashMap<>();
        for(Match match : matches) {
            venueMap.put(Integer.parseInt(match.getId()),match.getCity());
        }
        
        for (Delivery balls : deliveries) {
            if(Integer.parseInt(balls.getBatsmanRuns()) == 4) {
                String venue = venueMap.get(Integer.parseInt(balls.getMatchId()));
                if(theBoundariesByPlayerInEachVenue.containsKey(venue)) {
                    Map<String, Integer> ans = theBoundariesByPlayerInEachVenue.get(venue);
                    if(ans.containsKey(balls.getBatsman())) {
                        ans.put(balls.getBatsman(),ans.get(balls.getBatsman() + 1));
                    }
                    else {
                        ans.put(balls.getBatsman(), 1);
                    }
                    theBoundariesByPlayerInEachVenue.put(venue,ans);
                }
                else {
                    Map<String, Integer> list = new HashMap<>();
                    list.put(balls.getBatsman(), 1);
                    theBoundariesByPlayerInEachVenue.put(venue,list);
                }
            }
        }
        for (Map.Entry<String, Map<String, Integer>> listOfEachVenueOfEachPlayerBoundary : theBoundariesByPlayerInEachVenue.entrySet()) {
            System.out.print(listOfEachVenueOfEachPlayerBoundary.getKey()+":- ");
            System.out.println(listOfEachVenueOfEachPlayerBoundary.getValue());
            System.out.println();
        }