Added Java Doc and Logger to Team

This commit is contained in:
Leonardo Brandenberger 2022-05-13 00:02:31 +02:00
parent e77d6cbc21
commit 072db996dc
1 changed files with 68 additions and 3 deletions

View File

@ -2,59 +2,124 @@ package ch.zhaw.projekt2.turnierverwaltung;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
/**
* Class Team represents a team that can be added to a tournament
* (in the prototype there is no functionality for the team)
*/
public class Team implements Participant {
private String name;
private List<Player> players;
private Person contactPerson;
public Team(String name){
private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName());
/**
* Constructor to initiate a team, sets its name
*
* @param name the new name to be set
*/
public Team(String name) {
logger.fine("Setting the new name of the team as: " + name);
setName(name);
players = new ArrayList<>();
}
public void addPlayer(Player player){
/**
* Method to add a new player to a team
*
* @param player new player to be added to a team
*/
public void addPlayer(Player player) {
logger.fine("Adding new Player named: " + player + "into the team");
players.add(player);
}
/**
* Method to return the name of the team
*
* @return the name of the team
*/
@Override
public String getName() {
logger.fine("Returnining the name of the team:" + name);
return name;
}
/**
* @param name
*/
@Override
public void setName(String name) {
this.name = name;
}
/**
* Method that sets a complete List of all players as players of the team
*
* @param players List of Players to be set
*/
public void setPlayers(List<Player> players) {
logger.fine("Inserts Player");
this.players = players;
}
/**
* Method to get the List of all Players in a team
*
* @return List of all players in team
*/
public List<Player> getPlayers() {
logger.fine("Returning List of all players in " + getName());
return players;
}
/**
* Override of equals Method to compare teams with each other
*
* @param participant
* @return true if teams are the same false if not.
*/
@Override
public boolean equals(Participant participant) {
return getClass().equals(participant.getClass()) && toString().toLowerCase().equals(participant.toString().toLowerCase());
}
//TODO ???
@Override
public void change(Participant participant) {
return;
}
/**
* Method to get the current contact Person of a team
*
* @return
*/
public Person getContactPerson() {
logger.fine("Returning contact Person of team " + getName());
return contactPerson;
}
/**
* Method to set a Person as a contact person of a team
*
* @param contactPerson
*/
public void setContactPerson(Person contactPerson) {
logger.fine("Setting " + contactPerson + " as a contact Person for team " + getName());
this.contactPerson = contactPerson;
}
/**
* Override of toString method, that returns the current name
*
* @return name in form of a String
*/
@Override
public String toString(){
public String toString() {
return name;
}
}