From 30afecb379720255566b75c5a3fa013e05c17d84 Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 13 May 2022 23:57:31 +0200 Subject: [PATCH] javadoc --- .../main/gameScheduleView/GameDecorator.java | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java index 6be0905..1caa327 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java @@ -1,29 +1,51 @@ package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView; import ch.zhaw.projekt2.turnierverwaltung.*; - import java.util.ArrayList; import java.util.List; - +/** + * This Class is used by the GameController for additional functionality and holds the listeners and the Model Game + */ public class GameDecorator implements IsObservable{ private Game game; private List listener = new ArrayList<>(); + /** + * Setup the GameDecorator + * + * @param game Model for the Controller + */ public GameDecorator (Game game) { this.game = game; } + /** + * Method adds a new Listener to the listener list + * + * @param observer that is being added to the Listener List + */ @Override public void addListener(IsObserver observer) { listener.add(observer); } + /** + * Removes a Listener from the Listener List + * + * @param observer the Listener to be removed + */ @Override public void removeListener(IsObserver observer) { listener.remove(observer); } + /** + * Saves the Gameresult in the model + * + * @param points1 points achieved in textfield one + * @param points2 points achieved in textfield two + */ public void saveGameResult(String points1, String points2){ if(points1.length() > 0){ game.setPoints1(Integer.parseInt(points1)); @@ -38,19 +60,35 @@ public class GameDecorator implements IsObservable{ informListener(); } + /** + * Saves the Place in the Model + * + * @param place + */ public void saveGamePlace(Place place){ game.setPlace(place); informListener(); } + /** + * @return game points from player one + */ public String getPoints1() { return String.valueOf(game.getPoints1()); } + /** + * + *@return game points from player two + */ public String getPoints2() { return String.valueOf(game.getPoints2()); } + /** + * + * @return returns Gameparticipant one + */ public String getParticipantOne() { if (game.getParticipant1() != null) { return game.getParticipant1().toString(); @@ -58,6 +96,10 @@ public class GameDecorator implements IsObservable{ return "1"; } + /** + * + * @return returns Gameparticipant two + */ public String getParticipantTwo() { if (game.getParticipant2() != null) { return game.getParticipant2().toString(); @@ -65,15 +107,25 @@ public class GameDecorator implements IsObservable{ return "2"; } + /** + * calls method in model to refresh participant + */ public void refreshParticipants(){ game.refreshParticipants(); informListener(); } + /** + * + * @return place + */ public Place getPlace() { return game.getPlace(); } + /** + * Method that informs all listeners of an update. + */ public void informListener() { for(IsObserver observer : listener) { observer.update();