|
@ -2,9 +2,38 @@ package ch.zhaw.projekt2.turnierverwaltung;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Interface that defines the common functionality of a Participant, used by Players and Teams
|
||||
*/
|
||||
public interface Participant extends Serializable {
|
||||
/**
|
||||
* Method that will be used to get
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Method to set a participants name
|
||||
*
|
||||
* @param name to be set
|
||||
* @throws InvalidNameException if the name does not follow the correct format
|
||||
*/
|
||||
void setName(String name) throws InvalidNameException;
|
||||
|
||||
/**
|
||||
* Method to compare two participants with each other
|
||||
*
|
||||
* @param participant to be compared to the current instance
|
||||
* @return true if equal, false if not
|
||||
*/
|
||||
boolean equals(Participant participant);
|
||||
|
||||
/**
|
||||
* Method to change out participants
|
||||
*
|
||||
* @param participant to be exchanged
|
||||
* @throws Person.InvalidPhoneNumberException if phone number does not follow the correct formatting
|
||||
*/
|
||||
void change(Participant participant) throws Person.InvalidPhoneNumberException;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public class Person implements Serializable {
|
|||
/**
|
||||
* Exception, that is used when a Phone number is in an invalid format.
|
||||
*/
|
||||
public class InvalidPhoneNumberException extends Exception {
|
||||
public static class InvalidPhoneNumberException extends Exception {
|
||||
|
||||
public InvalidPhoneNumberException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class Place implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Ovveride of toString to return the name as String when needed
|
||||
* Override of toString to return the name as String when needed
|
||||
*
|
||||
* @return the name of the place as String
|
||||
*/
|
||||
|
@ -68,7 +68,11 @@ public class Place implements Serializable {
|
|||
return name.equals(place.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Functionality to save more details than the name about a place is not implemented in this prototype,
|
||||
* so no functionality is set yet to change the place.
|
||||
* @param place to be changed
|
||||
*/
|
||||
public void change(Place place) {
|
||||
//TODO: If Place gets more developed in future releases
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,12 +50,11 @@ public class Player extends Person implements Participant {
|
|||
* @return String of formatted date
|
||||
*/
|
||||
public String getFormattedDateOfBirth() {
|
||||
logger.finer("Trying to get the formated date");
|
||||
logger.finer("Trying to get the formatted date");
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
logger.fine("Returning the formatted birthdate of player: " + getName());
|
||||
return dateOfBirth.format(
|
||||
formatter);
|
||||
return dateOfBirth.format(formatter);
|
||||
} catch (Exception e) {
|
||||
logger.warning("Failed to get formatted date for player " + getName() + "Error: " + e);
|
||||
//TODO handle
|
||||
|
@ -122,11 +121,7 @@ public class Player extends Person implements Participant {
|
|||
setPhoneNumber(player.getPhoneNumber());
|
||||
}
|
||||
|
||||
public class InvalidDateException extends Exception {
|
||||
public InvalidDateException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static class InvalidDateException extends Exception {
|
||||
public InvalidDateException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
|
|
@ -44,12 +44,14 @@ public class Team implements Participant {
|
|||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
logger.fine("Returnining the name of the team:" + name);
|
||||
logger.fine("Returning the name of the team:" + name);
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Method to set the name of a team
|
||||
*
|
||||
* @param name of the team
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
|
@ -84,7 +86,7 @@ public class Team implements Participant {
|
|||
*/
|
||||
@Override
|
||||
public boolean equals(Participant participant) {
|
||||
return getClass().equals(participant.getClass()) && toString().toLowerCase().equals(participant.toString().toLowerCase());
|
||||
return getClass().equals(participant.getClass()) && toString().equalsIgnoreCase(participant.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,9 +99,9 @@ public class Team implements Participant {
|
|||
}
|
||||
|
||||
/**
|
||||
* Method to get the current contact Person of a team
|
||||
* Method to get the current contact person of a team
|
||||
*
|
||||
* @return
|
||||
* @return the current contact person
|
||||
*/
|
||||
public Person getContactPerson() {
|
||||
logger.fine("Returning contact Person of team " + getName());
|
||||
|
@ -109,7 +111,7 @@ public class Team implements Participant {
|
|||
/**
|
||||
* Method to set a Person as a contact person of a team
|
||||
*
|
||||
* @param contactPerson
|
||||
* @param contactPerson to be set
|
||||
*/
|
||||
public void setContactPerson(Person contactPerson) {
|
||||
logger.fine("Setting " + contactPerson + " as a contact Person for team " + getName());
|
||||
|
|
|
@ -157,10 +157,8 @@ public class Tournament implements Serializable {
|
|||
logger.warning("Invalid number of participants only participants 2^n allowed");
|
||||
throw new NumberOfParticipantInvalidException("Can not Create Game Schedule for KO Modus");
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
logger.warning("In the prototype the only accessible game schedule is the ko mods");
|
||||
logger.warning("In the prototype the only accessible game schedule is the ko modus");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue