Merge branch 'main' into refactoring_of_factory
This commit is contained in:
@@ -29,4 +29,8 @@ public class Place implements Serializable {
|
||||
public boolean equals(Place place){
|
||||
return name.equals(place.getName());
|
||||
}
|
||||
|
||||
public void change(Place place) {
|
||||
//TODO: If Place gets more developed in future releases
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -107,10 +108,14 @@ public class Tournament implements Serializable {
|
||||
* Method to add a new Place, also checks if place does already exist.
|
||||
*
|
||||
* @param newPlace to be added in the list of all places
|
||||
* @throws PlaceExistsException if the place already exists
|
||||
*/
|
||||
public void addPlace(Place newPlace) throws PlaceExistsException {
|
||||
places.removeIf(place -> place.equals(newPlace));
|
||||
public void savePlace(Place newPlace) {
|
||||
for (Place place : places) {
|
||||
if (place.equals(newPlace)) {
|
||||
place.change(newPlace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
places.add(newPlace);
|
||||
}
|
||||
|
||||
@@ -228,7 +233,7 @@ public class Tournament implements Serializable {
|
||||
* @param 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);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -295,20 +300,6 @@ public class Tournament implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Exception thrown when a Place does already exist
|
||||
*/
|
||||
public class PlaceExistsException extends Exception {
|
||||
public PlaceExistsException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PlaceExistsException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Exception thrown when a Place does not exist
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ public class TournamentDecorator implements IsObservable{
|
||||
}
|
||||
}
|
||||
});
|
||||
executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
executorService = Executors.newFixedThreadPool(1);
|
||||
}
|
||||
|
||||
public void setFactoryDecorator(FactoryDecorator factoryDecorator) {
|
||||
@@ -148,13 +148,9 @@ public class TournamentDecorator implements IsObservable{
|
||||
|
||||
public void savePlace(String name){
|
||||
try {
|
||||
tournament.addPlace(new Place(name));
|
||||
tournament.savePlace(new Place(name));
|
||||
factoryDecorator.clearMessage(true);
|
||||
informListener();
|
||||
} catch (Tournament.PlaceExistsException e) {
|
||||
e.printStackTrace(); //TODO handle and logging
|
||||
factoryDecorator.printMessageToFooter("Ort existiert bereits",true);
|
||||
|
||||
} catch (InvalidNameException e) {
|
||||
e.printStackTrace(); //TODO handle and logging
|
||||
factoryDecorator.printMessageToFooter("Invalider Ortsname",true);
|
||||
|
||||
Reference in New Issue
Block a user