From 06ad28fbe8541a4b62b5b4d38222bdce42906e60 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Fri, 18 Mar 2022 09:58:13 +0100 Subject: [PATCH] implemented getWinner method --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 44c5bde..ac0b81e 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -121,7 +121,12 @@ public class Game implements GameSpecification { */ @Override public int getWinner() { - // TODO: implementation + List cars = track.getCars(); + for (Car car: cars) { + if(car.getWinPoints() == 1){ + return car.getID(); + } + } return NO_WINNER; }