From 072db996dc9994f149345c57e12719b579a48e8a Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Fri, 13 May 2022 00:02:31 +0200 Subject: [PATCH] Added Java Doc and Logger to Team --- .../zhaw/projekt2/turnierverwaltung/Team.java | 71 ++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java index 8a2a0ba..5d31099 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java @@ -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 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 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 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; } }