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
3 changed files with 46 additions and 6 deletions
Showing only changes of commit 7267fe590b - Show all commits

View File

@ -1,32 +1,70 @@
package ch.zhaw.projekt2.turnierverwaltung;
import java.io.Serializable;
import java.util.logging.Logger;
/**
* Class Representing a place that can be set for a game
*/
public class Place implements Serializable {
private final String NAME_MATCHING_REGEX = "[a-zA-Z0-9]{1,20}";
private String name;
private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName());
/**
* Constructor of a place initializes it and checks if name is in valid format
*
* @param name to be set
* @throws InvalidNameException If name is invalid
*/
public Place(String name) throws InvalidNameException {
if (!name.matches(NAME_MATCHING_REGEX)) {
throw new InvalidNameException("The Name is Invalid.");
logger.warning("Name: " + name + " does not follow the valid format");
throw new InvalidNameException("The Name: " + name + " is in an invalid Format");
}
logger.fine("Name: " + name + " is valid and will be set for the Place");
setName(name);
}
/**
* Method to get the Name of the Place as String
*
* @return name of place as String
*/
public String getName() {
logger.finer("returning the name: " + name);
return name;
}
public void setName(String name) {
/**
* Method to set the name of a place
*
* @param name the name to be set
*/
private void setName(String name) {
logger.finer("Setting " + name + " as name of place");
this.name = name;
}
/**
* Ovveride of toString to return the name as String when needed
*
* @return the name of the place as String
*/
@Override
public String toString() {
return name;
}
/**
* Override of equals tom compare places with each other
*
* @param place to be compared with this instance
* @return true if equals and false if not equal
*/
public boolean equals(Place place) {
logger.fine("Comparing " + place + " with " + this);
return name.equals(place.getName());
}
}

View File

@ -64,6 +64,7 @@ public class Player extends Person implements Participant {
/**
* Method to set the date of Birth with a String provided.
*
* @param dateOfBirth to be as a String
*/
public void setDateOfBirth(String dateOfBirth) {

View File

@ -2,6 +2,7 @@ package ch.zhaw.projekt2.turnierverwaltung;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;