Added Java Doc and Logger to Place.java
This commit is contained in:
parent
befa159f90
commit
7267fe590b
|
@ -1,32 +1,70 @@
|
||||||
package ch.zhaw.projekt2.turnierverwaltung;
|
package ch.zhaw.projekt2.turnierverwaltung;
|
||||||
|
|
||||||
import java.io.Serializable;
|
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 {
|
public class Place implements Serializable {
|
||||||
private final String NAME_MATCHING_REGEX = "[a-zA-Z0-9]{1,20}";
|
private final String NAME_MATCHING_REGEX = "[a-zA-Z0-9]{1,20}";
|
||||||
private String name;
|
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 {
|
public Place(String name) throws InvalidNameException {
|
||||||
if (!name.matches(NAME_MATCHING_REGEX)) {
|
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);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the Name of the Place as String
|
||||||
|
*
|
||||||
|
* @return name of place as String
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
logger.finer("returning the name: " + name);
|
||||||
return 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;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ovveride of toString to return the name as String when needed
|
||||||
|
*
|
||||||
|
* @return the name of the place as String
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
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) {
|
public boolean equals(Place place) {
|
||||||
|
logger.fine("Comparing " + place + " with " + this);
|
||||||
return name.equals(place.getName());
|
return name.equals(place.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class Player extends Person implements Participant {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to set the date of Birth with a String provided.
|
* Method to set the date of Birth with a String provided.
|
||||||
|
*
|
||||||
* @param dateOfBirth to be as a String
|
* @param dateOfBirth to be as a String
|
||||||
*/
|
*/
|
||||||
public void setDateOfBirth(String dateOfBirth) {
|
public void setDateOfBirth(String dateOfBirth) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package ch.zhaw.projekt2.turnierverwaltung;
|
||||||
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
Loading…
Reference in New Issue