Add: Added Javadoc For "toStringBoard" Method In CavePaintings.java.

This commit is contained in:
GabrieleRadice
2026-04-30 16:41:14 +02:00
parent 1af39bc558
commit 3c0ea0f9eb
3 changed files with 36 additions and 14 deletions
@@ -89,13 +89,19 @@ public class CavePaintings extends EventCard {
/**
* Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
* toString to print a more detailed version; includes: {@code NLower}, {@code NUpper}, {@code NPrestigeRem} and {@code NPrestigeMul}.
* toString to print a more detailed version.
* <p>NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code NLower} is needed),
* however it's a parameter on the cards' design.
* </p>
* <p>includes:
* <li>{@link #NLower}
* <li>{@code NUpper}
* <li>{@link #NPrestigeRem}
* <li>{@link #NPrestigeMul}
* </p>
* @return {@code String} - a string representation of this {@code TribeCard}.
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
* @see it.polimi.ingsw.gc14.Model.Game Game
* @see #NLower
* @see #NPrestigeRem
* @see #NPrestigeMul
*/
@Override
public String toStringBoard() {
@@ -8,7 +8,6 @@ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static it.polimi.ingsw.gc14.View.TUI.BorderStyle.*;
@@ -228,17 +227,34 @@ public class Player implements Serializable {
// endregion constructors
// region Functions
/**
* Prints the {@code Player}'s attributes for the {@code Board}'s representation.
* Uses the {@code UNICODE} border style.
* <p><b>Includes:</b>
* <li>{@link #FoodValue Food}
* <li>{@link #PrestigeValue Prestige}
* <li>{@link #artists Artists}
* <li>{@link #builders Builders}
* <li>{@link #gatherers Gatherers}
* <li>{@link #shamans Shamans}
* <li>{@link #inventors Inventors}
* <li>{@link #hunters Hunters}
* <li>{@link #buildingCards Buildings}
* </p>
* @return {@code String} - A string representation of the {@code Player}'s attributes.
* @see it.polimi.ingsw.gc14.View.TUI.BorderStyle BorderStyle
*/
@Override
public String toString() {
int Last = 6;
int Last = -1;
var table = new AsciiTable(UNICODE, 1);
table.addHeader(this.getUserName());
table.addRow("RESOURCES:");
table.addRow("Food: " + this.getFoodValue());
table.addSeparator();
table.addRow("Prestige: " + this.getPrestigeValue());
table.addSeparator();
if(!this.hunters.isEmpty()){
Last = 6;
@@ -267,44 +283,44 @@ public class Player implements Serializable {
}
table.addRow("CHARACTERS:");
if(!this.artists.isEmpty()){
table.addRow("Artists: " + this.artists.toString());
if(Last == 1){
table.addSeparator();
}
table.addRow("Artists: " + this.artists.toString());
}
if(!this.builders.isEmpty()){
table.addRow("Builders: " + this.builders.toString());
if(Last == 2){
table.addSeparator();
}
table.addRow("Builders: " + this.builders.toString());
}
if(!this.gatherers.isEmpty()){
table.addRow("Gatherers: " + this.gatherers.toString());
if(Last == 3){
table.addSeparator();
}
table.addRow("Gatherers: " + this.gatherers.toString());
}
if(!this.shamans.isEmpty()){
table.addRow("Shamans: " + this.shamans.toString());
if(Last == 4){
table.addSeparator();
}
table.addRow("Shamans: " + this.shamans.toString());
}
if(!this.inventors.isEmpty()){
table.addRow("Inventors: " + this.inventors.toString());
if(Last == 5){
table.addSeparator();
}
table.addRow("Inventors: " + this.inventors.toString());
}
if(!this.hunters.isEmpty()){
table.addSeparator();
table.addRow("Hunters: " + this.hunters.toString());
table.addSeparator();
}
table.addRow("BUILDING CARDS:");
@@ -15,7 +15,7 @@ public class AsciiTable {
public void addRow(String... cells) { rows.add(Arrays.asList(cells)); }
public void addRow(List<String> cells) { rows.add(cells); }
public void addHeader(String... cells) { rows.add(0, Arrays.asList(cells)); separators.add(0); }
public void addSeparator() { separators.add(rows.size()); }
public void addSeparator() { separators.add(rows.size()-1); }
public String build() {
var sb = new StringBuilder();