From fb408a3f782a3e7abed636f4b84d4020fa8a7855 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 9 Dec 2021 16:07:03 +0100 Subject: [PATCH] update javadoc from package client.view --- .../java/fr/lnl/game/client/view/Cell.java | 10 ++-- .../fr/lnl/game/client/view/ViewManager.java | 50 +++++++------------ 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/client/src/main/java/fr/lnl/game/client/view/Cell.java b/client/src/main/java/fr/lnl/game/client/view/Cell.java index 8383099..caa47ad 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Cell.java +++ b/client/src/main/java/fr/lnl/game/client/view/Cell.java @@ -37,13 +37,15 @@ public class Cell extends Rectangle { public Cell(int x, int y){ setWidth(Window.cellSize); setHeight(Window.cellSize); - relocate(x*Window.cellSize,y*Window.cellSize); - setFill(Color.valueOf("#ffffff")); + relocate(x * Window.cellSize,y * Window.cellSize); + setFill(Color.WHITE); setStroke(Color.DARKGRAY); } - - + /** + * @param object the object we'll define the type + * @return a pane which contains an image depending on the type of the object + */ public static StackPane setImageObject(Object object, Game game){ StackPane sp = new StackPane(); Image in; diff --git a/client/src/main/java/fr/lnl/game/client/view/ViewManager.java b/client/src/main/java/fr/lnl/game/client/view/ViewManager.java index b3ccd57..6fd2a21 100644 --- a/client/src/main/java/fr/lnl/game/client/view/ViewManager.java +++ b/client/src/main/java/fr/lnl/game/client/view/ViewManager.java @@ -11,9 +11,14 @@ import java.util.HashMap; import java.util.Objects; import java.util.Scanner; +/** + * View manager, main access to every views + */ public final class ViewManager { + private final Game game; private final Class viewType; + public HashMap players = new HashMap<>(); public ViewManager(Game game, Class viewType, ViewLambda lambda) { this.game = game; @@ -23,13 +28,16 @@ public final class ViewManager { } } - - public HashMap players = new HashMap<>(); - + /** + * Call when we need to change or update view + */ public void updateView() { players.get(game.getCurrentPlayer()).getView().show(); } + /** + * This method is call when the view is a terminal + */ public void terminalView() { Terminal.scanner = new Scanner(System.in); DisplayWinnerEvent displayWinnerEvent = new DisplayWinnerEvent(); @@ -52,10 +60,17 @@ public final class ViewManager { } } + /** + * This method is call when the game is finish + * @param winner The winner of the game, can be null + */ public void displayWinner(Player winner) { players.get(game.getCurrentPlayer()).getView().displayWinner(winner); } + /** + * This method is call after initialized view manager to display a first screen + */ public void run() { if (viewType == Terminal.class) { terminalView(); @@ -64,33 +79,4 @@ public final class ViewManager { } } - public Game game() { - return game; - } - - public Class viewType() { - return viewType; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) return true; - if (obj == null || obj.getClass() != this.getClass()) return false; - var that = (ViewManager) obj; - return Objects.equals(this.game, that.game) && - Objects.equals(this.viewType, that.viewType); - } - - @Override - public int hashCode() { - return Objects.hash(game, viewType); - } - - @Override - public String toString() { - return "ViewManager[" + - "game=" + game + ", " + - "viewType=" + viewType + ']'; - } - }