Logging and docs added to classes Person, Place and Player #27 #28 #50

Merged
brandleo merged 10 commits from logging_and_docs into main 2022-05-13 17:49:39 +02:00
1 changed files with 68 additions and 3 deletions
Showing only changes of commit 072db996dc - Show all commits

View File

@ -2,59 +2,124 @@ package ch.zhaw.projekt2.turnierverwaltung;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 { public class Team implements Participant {
private String name; private String name;
private List<Player> players; private List<Player> players;
private Person contactPerson; 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); setName(name);
players = new ArrayList<>(); 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); players.add(player);
} }
/**
* Method to return the name of the team
*
* @return the name of the team
*/
@Override @Override
public String getName() { public String getName() {
logger.fine("Returnining the name of the team:" + name);
return name; return name;
} }
/**
* @param name
*/
@Override @Override
public void setName(String name) { public void setName(String name) {
this.name = 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) { public void setPlayers(List<Player> players) {
logger.fine("Inserts Player");
this.players = players; 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() { public List<Player> getPlayers() {
logger.fine("Returning List of all players in " + getName());
return players; 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 @Override
public boolean equals(Participant participant) { public boolean equals(Participant participant) {
return getClass().equals(participant.getClass()) && toString().toLowerCase().equals(participant.toString().toLowerCase()); return getClass().equals(participant.getClass()) && toString().toLowerCase().equals(participant.toString().toLowerCase());
} }
//TODO ???
@Override @Override
public void change(Participant participant) { public void change(Participant participant) {
return; return;
} }
/**
* Method to get the current contact Person of a team
*
* @return
*/
public Person getContactPerson() { public Person getContactPerson() {
logger.fine("Returning contact Person of team " + getName());
return contactPerson; return contactPerson;
} }
/**
* Method to set a Person as a contact person of a team
*
* @param contactPerson
*/
public void setContactPerson(Person contactPerson) { public void setContactPerson(Person contactPerson) {
logger.fine("Setting " + contactPerson + " as a contact Person for team " + getName());
this.contactPerson = contactPerson; this.contactPerson = contactPerson;
} }
/**
* Override of toString method, that returns the current name
*
* @return name in form of a String
*/
@Override @Override
public String toString(){ public String toString() {
return name; return name;
} }
} }