Bowling game project
Hello, I am learning java for 3 days and I deal with that bowling game. I am trying to solve the problem with the following code but I don't understand (for now) the errors. Am I on the right way or should I use the "iterator" ? I get lost between the several possibilities. import java.util.*; public class Bowling { HashMap<String, Integer> players; Bowling() { players = new HashMap<String, Integer>(); } public void addPlayer(String name, int p) { players.put(name, p); } public void getWinner(); int maxValueHashMap=(Collections.max(players.values())); // je recherche la valeur maxiamle parmi les valeurs for (Entry<String, Integer> entry : players.entrySet()); { // Iterate through the map if (entry.getValue()==maxValueHashMap) { //if entry == maxValueMap System.out.println(entry.getKey()); // Print the key with max value } } } public class Program { public static void main(String[ ] args) { Bowling game = new Bowling(); Scanner sc = new Scanner(System.in); for(int i=0;i<3;i++) { String input = sc.nextLine(); String[] values = input.split(" "); String name = values[0]; int points = Integer.parseInt(values[1]); game.addPlayer(name, points); } game.getWinner(); } }