0

getWinner()

I need to add the getWinner(); method to the class, how can I do this? What did I do wrong in the code? import java.util.Scanner; public class Bowling { HashMap<String, Integer> players; Bowling() { players = new HashMap<String, Integer>(); } public void addPlayer(String name, int p) { players.put(name, p); } //your code goes here public void getWinner(); Iterator it = addPlayer().iterator(); while (it.hasNext()) { Map.addPlayer st = (Map.addPlayer)it.next(); System.out.println(st.getWinner() + st.getpoints() ); it.remove(); } } 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(); } }

12th Oct 2022, 4:24 PM
Akridem
Akridem - avatar
1 Answer
+ 1
You need to implement getWinner() method as per task description... Revise your previous lessons to know how to do..! See example carefully... Post your try then if not work.. happy learning.
12th Oct 2022, 6:27 PM
Jayakrishna 🇼🇳