From 9bedea385534b8b5e9d8b80cb8badb3fd6006153 Mon Sep 17 00:00:00 2001 From: rubenpirreram Date: Sun, 3 May 2026 17:59:34 +0200 Subject: [PATCH] Add: TUI javadoc --- .../it/polimi/ingsw/gc14/View/TUI/TUI.java | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java b/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java index 6321900..19dac09 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java @@ -6,33 +6,52 @@ import java.util.List; public class TUI implements IView { - /** - * The style of the table - */ - private BorderStyle style = BorderStyle.UNICODE; /** * The {@link it.polimi.ingsw.gc14.Model.Game } model stored for the game status render */ private Game model; + + /** + * The {@link it.polimi.ingsw.gc14.Model.Player } username stored for the player hand render + */ private String username; + + /** + * Constructor for the class {@code TUI} + * @param model The model that will be display + */ public TUI(Game model) { this.model = model; this.username=""; } + + /** + * Set the {@code Username} of the player, used for the hand player display + * @param username + */ public void setUsername(String username) { this.username = username; } + /** + * Update {@link it.polimi.ingsw.gc14.Model.Game } model stored for the game status render + */ @Override public void update(Game model) { this.model = model; } - // ── punto di ingresso ─────────────────────────────────────── + /** + * Default method called to display homepage , implements {@link IView} + */ public void render() { renderBoard(); } + + /** + * Method called to display players status and board status + */ public void fullRender() { try{ @@ -53,6 +72,9 @@ public class TUI implements IView { System.out.println(model.PlayersStamp()+"\n"+ AsciiTable.sideBySide(lines,lines2,3)); } + /** + * Method called to display board status + */ public void renderBoard() { try{ @@ -71,6 +93,9 @@ public class TUI implements IView { List lines2=List.of((PrintMenuOptions()+"\nYOUR HAND\n"+model.getPlayerByUsername(username)).split("\n")); System.out.println(AsciiTable.sideBySide(lines,lines2,3)); } + /** + * Method called to display player status + */ public void renderPlayer() { try{ @@ -90,17 +115,26 @@ public class TUI implements IView { System.out.println(AsciiTable.sideBySide(lines,lines2,3)); } + /** + * Method called to display a message on the terminal + */ public void showMessage(String message) { System.out.println(message); } - + /** + * Method called to display a error on the terminal + */ public void showError(String message) { System.out.println(message); } + /** + * Method used to set up menu options + * @return the string format of the menu options + */ private String PrintMenuOptions() { var table=new AsciiTable(BorderStyle.ROUNDED,2);