Add: Partial Implementation Of The toString Method And Test in Player.java And PlayerTest.java II.
This commit is contained in:
@@ -226,14 +226,21 @@ public class Player {
|
|||||||
// TODO tostring usr + food + prestige \n tab foreach(characters.cards + spazio)
|
// TODO tostring usr + food + prestige \n tab foreach(characters.cards + spazio)
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getUserName() + ":\n\tFood: " + this.getFoodValue()
|
String toPrint = "";
|
||||||
|
toPrint = this.getUserName() + ":\n\tFood: " + this.getFoodValue()
|
||||||
+ "\n\tPrestige: " + this.getPrestigeValue()
|
+ "\n\tPrestige: " + this.getPrestigeValue()
|
||||||
+ "\n\tArtists: " + this.artists.toString()
|
+ "\n\tArtists: " + this.artists.toString()
|
||||||
+ "\n\tBuilders: " + this.builders.toString()
|
+ "\n\tBuilders: " + this.builders.toString()
|
||||||
+ "\n\tGatherers: " + this.gatherers.toString()
|
+ "\n\tGatherers: " + this.gatherers.toString()
|
||||||
+ "\n\tShamans: " + this.shamans.toString()
|
+ "\n\tShamans: " + this.shamans.toString()
|
||||||
+ "\n\tHunters: " + this.hunters.toString()
|
+ "\n\tHunters: " + this.hunters.toString()
|
||||||
+ "\n\tBuildings:" + this.buildingCards.toString().indent(1);
|
+ "\n\tBuildings: \n";
|
||||||
|
for (BuildingCard buildingCard : this.buildingCards) {
|
||||||
|
toPrint += buildingCard.toString().indent(8);
|
||||||
|
toPrint += toPrint.replaceAll("\\n$", "") + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
return toPrint;
|
||||||
}
|
}
|
||||||
// endregion functions
|
// endregion functions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.polimi.ingsw.gc14.Model;
|
package it.polimi.ingsw.gc14.Model;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
@@ -192,4 +193,14 @@ class PlayerTest {
|
|||||||
Player p = new Player("");
|
Player p = new Player("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void tostring() {
|
||||||
|
Player p = new Player("test_usr");
|
||||||
|
p.addPrestige(15);
|
||||||
|
p.addFood(7);
|
||||||
|
p.buildingCards.add(new BuildingCard(1,2, 5));
|
||||||
|
p.buildingCards.add(new BuildingCard(2,3, 6));
|
||||||
|
System.out.println(p.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user