I found a task for Java beginners. It is a interface which i have to implement. I decided to use HashMap for Players, but now i noticed that i have to return an array of Player, right? Can you help me to understand how can i do it in getAllPlayers() method, please? Thank you
public class LeagueManager implements Manager{
Map<String, Player> players = new HashMap<String, Player>();
public void addPlayer(Player player) {
players.put(player.getNick(), player);
}
public void removePlayer(Player player) {
if (!players.isEmpty()) {
players.remove(player.getNick());
}
}
public Player getPlayer(String name) {
if (!players.isEmpty() && players.containsKey(name)) {
return (Player) players.get(name);
} else {
System.out.println("Error: there is no player with nick " + name);
return null;
}
}
public Player[] getAllPlayers() {
if (!players.isEmpty()) {
return null;
} else {
return null;
}
}
public void addPoints (String name, int points) {
if (players.containsKey(name)) {
Player pl = (Player) players.get(name);
pl.setPoints(points);
}
}}