From 02456bc5bf7850736427f939e91e6ff0758bf620 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 6 May 2022 09:23:19 +0200 Subject: [PATCH] fixed participanFormular and placesFormular #19 --- .../zhaw/projekt2/turnierverwaltung/Tournament.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java index a40585a..b4097d5 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; public class Tournament implements Serializable { @@ -31,11 +32,7 @@ public class Tournament implements Serializable { } public void addParticipant(Participant newParticipant) throws ParticipantExistsException { - for(Participant participant : participants){ - if(participant.equals(newParticipant)){ - participants.remove(participant); - } - } + participants.removeIf(participant -> participant.equals(newParticipant)); participants.add(newParticipant); } @@ -53,11 +50,7 @@ public class Tournament implements Serializable { } public void addPlace(Place newPlace) throws PlaceExistsException { - for(Place place : places){ - if(place.equals(newPlace)){ - places.remove(place); - } - } + places.removeIf(place -> place.equals(newPlace)); places.add(newPlace); } -- 2.40.1