throw PlaceExistsExceptoin if place exists already.
This commit is contained in:
parent
92d121890c
commit
54a428cde2
|
@ -110,7 +110,11 @@ public class Tournament implements Serializable {
|
|||
* @throws PlaceExistsException if the place already exists
|
||||
*/
|
||||
public void addPlace(Place newPlace) throws PlaceExistsException {
|
||||
places.removeIf(place -> place.equals(newPlace));
|
||||
for(Place place : places){
|
||||
if(place.getName().equals(newPlace.getName())){
|
||||
throw new PlaceExistsException("Place with same name exists already.");
|
||||
}
|
||||
}
|
||||
places.add(newPlace);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue