Add: TUI javadoc

This commit is contained in:
rubenpirreram
2026-05-03 17:59:34 +02:00
parent b5316e37b4
commit 9bedea3855
@@ -6,33 +6,52 @@ import java.util.List;
public class TUI implements IView { 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 * The {@link it.polimi.ingsw.gc14.Model.Game } model stored for the game status render
*/ */
private Game model; private Game model;
/**
* The {@link it.polimi.ingsw.gc14.Model.Player } username stored for the player hand render
*/
private String username; private String username;
/**
* Constructor for the class {@code TUI}
* @param model The model that will be display
*/
public TUI(Game model) { public TUI(Game model) {
this.model = model; this.model = model;
this.username=""; this.username="";
} }
/**
* Set the {@code Username} of the player, used for the hand player display
* @param username
*/
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/**
* Update {@link it.polimi.ingsw.gc14.Model.Game } model stored for the game status render
*/
@Override @Override
public void update(Game model) { public void update(Game model) {
this.model = model; this.model = model;
} }
// ── punto di ingresso ─────────────────────────────────────── /**
* Default method called to display homepage , implements {@link IView}
*/
public void render() public void render()
{ {
renderBoard(); renderBoard();
} }
/**
* Method called to display players status and board status
*/
public void fullRender() public void fullRender()
{ {
try{ try{
@@ -53,6 +72,9 @@ public class TUI implements IView {
System.out.println(model.PlayersStamp()+"\n"+ AsciiTable.sideBySide(lines,lines2,3)); System.out.println(model.PlayersStamp()+"\n"+ AsciiTable.sideBySide(lines,lines2,3));
} }
/**
* Method called to display board status
*/
public void renderBoard() public void renderBoard()
{ {
try{ try{
@@ -71,6 +93,9 @@ public class TUI implements IView {
List<String> lines2=List.of((PrintMenuOptions()+"\nYOUR HAND\n"+model.getPlayerByUsername(username)).split("\n")); List<String> lines2=List.of((PrintMenuOptions()+"\nYOUR HAND\n"+model.getPlayerByUsername(username)).split("\n"));
System.out.println(AsciiTable.sideBySide(lines,lines2,3)); System.out.println(AsciiTable.sideBySide(lines,lines2,3));
} }
/**
* Method called to display player status
*/
public void renderPlayer() public void renderPlayer()
{ {
try{ try{
@@ -90,17 +115,26 @@ public class TUI implements IView {
System.out.println(AsciiTable.sideBySide(lines,lines2,3)); System.out.println(AsciiTable.sideBySide(lines,lines2,3));
} }
/**
* Method called to display a message on the terminal
*/
public void showMessage(String message) public void showMessage(String message)
{ {
System.out.println(message); System.out.println(message);
} }
/**
* Method called to display a error on the terminal
*/
public void showError(String message) public void showError(String message)
{ {
System.out.println(message); System.out.println(message);
} }
/**
* Method used to set up menu options
* @return the string format of the menu options
*/
private String PrintMenuOptions() private String PrintMenuOptions()
{ {
var table=new AsciiTable(BorderStyle.ROUNDED,2); var table=new AsciiTable(BorderStyle.ROUNDED,2);