CodeCleanup in Player, Tournament and Participant
This commit is contained in:
parent
67003ad772
commit
f38b8aff16
|
@ -74,7 +74,7 @@ public class Player extends Person implements Participant {
|
||||||
if (dateOfBirth.length() > 0) {
|
if (dateOfBirth.length() > 0) {
|
||||||
String[] date = dateOfBirth.split("\\.");
|
String[] date = dateOfBirth.split("\\.");
|
||||||
try {
|
try {
|
||||||
this.dateOfBirth = LocalDate.of(Integer.valueOf(date[2]), Integer.valueOf(date[1]), Integer.valueOf(date[0]));
|
this.dateOfBirth = LocalDate.of(Integer.parseInt(date[2]), Integer.parseInt(date[1]), Integer.parseInt(date[0]));
|
||||||
logger.fine("Date of birth of" + getName() + " has been set to " + dateOfBirth);
|
logger.fine("Date of birth of" + getName() + " has been set to " + dateOfBirth);
|
||||||
} catch (NumberFormatException | IndexOutOfBoundsException e) {
|
} catch (NumberFormatException | IndexOutOfBoundsException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -105,7 +105,7 @@ public class Player extends Person implements Participant {
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Participant participant) {
|
public boolean equals(Participant participant) {
|
||||||
logger.fine("Comparing " + participant + " with " + this);
|
logger.fine("Comparing " + participant + " with " + this);
|
||||||
return getClass().equals(participant.getClass()) && toString().toLowerCase().equals(participant.toString().toLowerCase());
|
return getClass().equals(participant.getClass()) && toString().equalsIgnoreCase(participant.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class Tournament implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Method to remove an existing participant throws error if participant could not be found
|
* Method to remove an existing participant throws error if participant could not be found
|
||||||
*
|
*
|
||||||
* @param participant
|
* @param participant to be removed
|
||||||
* @throws ParticipantNotExistsException
|
* @throws ParticipantNotExistsException thrown when the participant could not be found
|
||||||
*/
|
*/
|
||||||
public void removeParticipant(Participant participant) throws ParticipantNotExistsException {
|
public void removeParticipant(Participant participant) throws ParticipantNotExistsException {
|
||||||
logger.finer("Trying to remove " + participant + " from participants List");
|
logger.finer("Trying to remove " + participant + " from participants List");
|
||||||
|
@ -120,8 +120,9 @@ public class Tournament implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param place
|
* Method that removes a place from the List, also checks if place is in the list
|
||||||
* @throws PlaceNotExistsException
|
* @param place to be removed
|
||||||
|
* @throws PlaceNotExistsException thrown when the place could not be found
|
||||||
*/
|
*/
|
||||||
public void removePlace(Place place) throws PlaceNotExistsException {
|
public void removePlace(Place place) throws PlaceNotExistsException {
|
||||||
if (!places.contains(place)) {
|
if (!places.contains(place)) {
|
||||||
|
@ -159,7 +160,7 @@ public class Tournament implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.warning("In the prototype the only accessible game schedule is the ko modus");
|
logger.warning("In the prototype the only accessible game schedule is the ko mods");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +210,7 @@ public class Tournament implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settermethod for the name of the tournament
|
* Setter method for the name of the tournament
|
||||||
*
|
*
|
||||||
* @param name the new name that should be set
|
* @param name the new name that should be set
|
||||||
*/
|
*/
|
||||||
|
@ -218,7 +219,7 @@ public class Tournament implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gettermethod to get the type of the tournament
|
* Getter method to get the type of the tournament
|
||||||
*
|
*
|
||||||
* @return the type of the tournament
|
* @return the type of the tournament
|
||||||
*/
|
*/
|
||||||
|
@ -230,7 +231,7 @@ public class Tournament implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Setter Method to set the type of the tournament
|
* Setter Method to set the type of the tournament
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type the type to be set
|
||||||
*/
|
*/
|
||||||
public void setType(Type type) {
|
public void setType(Type type) {
|
||||||
logger.fine("Setting the type of the tournament to: " + type);
|
logger.fine("Setting the type of the tournament to: " + type);
|
||||||
|
@ -238,7 +239,7 @@ public class Tournament implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gettermethod to get the Complete GameList
|
* Getter method to get the Complete GameList
|
||||||
*
|
*
|
||||||
* @return the complete GameList
|
* @return the complete GameList
|
||||||
*/
|
*/
|
||||||
|
@ -254,17 +255,26 @@ public class Tournament implements Serializable {
|
||||||
public enum Type {
|
public enum Type {
|
||||||
KO("KO-System"); //GROUPS("Gruppenspiele"); //Type GROUPS is not implemented in this prototype.
|
KO("KO-System"); //GROUPS("Gruppenspiele"); //Type GROUPS is not implemented in this prototype.
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
private Type(String name) {
|
Type(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden toString method to return the name
|
||||||
|
* @return the name of the type
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to return an Observable List containing all types
|
||||||
|
*
|
||||||
|
* @return the Observable list with all types
|
||||||
|
*/
|
||||||
public static ObservableList<Type> getObservableList() {
|
public static ObservableList<Type> getObservableList() {
|
||||||
ObservableList<Type> items = FXCollections.observableArrayList();
|
ObservableList<Type> items = FXCollections.observableArrayList();
|
||||||
items.addAll(values());
|
items.addAll(values());
|
||||||
|
@ -275,11 +285,7 @@ public class Tournament implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Custom exception thrown when an invalid file is chosen
|
* Custom exception thrown when an invalid file is chosen
|
||||||
*/
|
*/
|
||||||
public class InvalidTypeException extends Exception {
|
public static class InvalidTypeException extends Exception {
|
||||||
public InvalidTypeException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvalidTypeException(String errorMessage) {
|
public InvalidTypeException(String errorMessage) {
|
||||||
super(errorMessage);
|
super(errorMessage);
|
||||||
}
|
}
|
||||||
|
@ -287,13 +293,9 @@ public class Tournament implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Expeption thrown when a Participant does not exist
|
* Custom Exception thrown when a Participant does not exist
|
||||||
*/
|
*/
|
||||||
public class ParticipantNotExistsException extends Exception {
|
public static class ParticipantNotExistsException extends Exception {
|
||||||
public ParticipantNotExistsException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParticipantNotExistsException(String errorMessage) {
|
public ParticipantNotExistsException(String errorMessage) {
|
||||||
super(errorMessage);
|
super(errorMessage);
|
||||||
}
|
}
|
||||||
|
@ -303,11 +305,7 @@ public class Tournament implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Custom Exception thrown when a Place does not exist
|
* Custom Exception thrown when a Place does not exist
|
||||||
*/
|
*/
|
||||||
public class PlaceNotExistsException extends Exception {
|
public static class PlaceNotExistsException extends Exception {
|
||||||
public PlaceNotExistsException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceNotExistsException(String errorMessage) {
|
public PlaceNotExistsException(String errorMessage) {
|
||||||
super(errorMessage);
|
super(errorMessage);
|
||||||
}
|
}
|
||||||
|
@ -317,11 +315,7 @@ public class Tournament implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Custom Exception thrown when the number of participants is not valid
|
* Custom Exception thrown when the number of participants is not valid
|
||||||
*/
|
*/
|
||||||
public class NumberOfParticipantInvalidException extends Exception {
|
public static class NumberOfParticipantInvalidException extends Exception {
|
||||||
public NumberOfParticipantInvalidException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NumberOfParticipantInvalidException(String msg) {
|
public NumberOfParticipantInvalidException(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue