System Specification
A local football club wishes to store information on its current squad of players:
Each Player’s personal information (first name, last name, age, height and weight) should be recorded in a class Person.
Each Player’s record for the season should be stored in a class Player.
The information stored for each player consists of the number of games played and goals scored.
Write a class Goalkeeper which in addition records the number of penalties that the goalkeeper has saved.
Provide appropriate methods for accessing this information.
You should make appropriate use of inheritance in your solution.
Information on all Players should be stored in a class Club.
Club stores the name of the club and maintains information about all of it's players.
Club has methods to add and remove Players addPlayer(Player p) and removePlayer(Player p).
It should also contain a method to retrieve a Player’s details given her/his first and last names.
(You may assume that no two Players have identical first and last names).
This part here doesnt work when I try to retrive the players details, i can retireve the name but not his age,weight,height etc- my method to retreive the information looks like this and i dunno what is wrong,say the player's name is Ryan Dun and blue j display this instead "Player's details: Ryan Dun2118789"
.
public void retrievePlayersInfo(String fName,String lName)
{
//while(fName&&lName)
String playerName = fName +" "+ lName;
for(int i=0;i<clubPlayers.size();i++)
{
Player p = clubPlayers.get(i);
if(p.getName().equals(playerName))
{
System.out.println("Player's details: " + p.getName() + p.getAge() +
p.getHeight() + p.getWeight());
}
}
}
Write classes Person, Player, Goalkeeper and Club that satisfy the above specification.
Write a class Test that contains a main method that tests your implementations and prints out the information held about each player in the club.
When a new player is signed, she/he should be inserted into the Club class in alphabetical order of last name (and first name if last names are the same).
To do this make your Person and Player class implement the appropriate Comparable interface.
Write a class ComparePlayers that implements the Comparator<Player> interface.
It should compare players by number of games played (and then by alphabetical order of surname if the number of games played is the same).
Implement a new Constructor for the Club class that takes a Comparator<Player> parameter.
Hence write a main program that will print information about each player in the club where players are listed by decreasing order of games played.
This should allow ordering to be dictated by the main program without modifying the code in any of your other classes.
Please could someone tell me what is it that i'm not getting right? Cheers:)