Merge pull request #18

Add: JavaDoc for Artist class
This commit is contained in:
GabrieleRadice
2026-04-12 18:15:02 +02:00
committed by GitHub
6 changed files with 199 additions and 17 deletions
@@ -7,26 +7,49 @@ import it.polimi.ingsw.gc14.Model.Player;
public class Artist extends Character { public class Artist extends Character {
/** /**
* Creates an Artist character card with the specified era.
* *
* param Era artist era * @param Era the era of the Artist card
*/ */
public Artist(int Era) { public Artist(int Era) {
super(Era, CharacterType.ARTIST); super(Era, CharacterType.ARTIST);
} }
/**
* Creates an Artist character card with the specified Era and minimum number of players required to play it.
*
* @param Era the era of the Artist card
* @param nMin the minimum number of players required for the card
*/
public Artist(int Era,int nMin) { public Artist(int Era,int nMin) {
super(Era, CharacterType.ARTIST,nMin); super(Era, CharacterType.ARTIST,nMin);
} }
/**
* Returns the string representation of this Artist card.
*
* @return the string representation of this Artist card.
*/
@Override @Override
public String toString() { public String toString() {
return super.toString(); return super.toString();
} }
/**
* Creates and returns a copy of this Artist card.
*
* @return a clone of this Artist card.
*/
@Override @Override
public Character clone() { public Character clone() {
return new Artist(getEra(), getNMin()); return new Artist(getEra(), getNMin());
} }
/**
* Inserts this Artist card into the specified player's Artist collection.
*
* @param player the player who receives the card.
*/
@Override @Override
public void insert(Player player) { public void insert(Player player) {
player.artists.add(this); player.artists.add(this);
@@ -6,19 +6,44 @@ import it.polimi.ingsw.gc14.Model.Player;
public class Builder extends Character public class Builder extends Character
{ {
private int reductionValue;
private int prestigeValue;
/** /**
* The reduction value provided by this Builder card.
*/
private int reductionValue;
/**
* The prestige value provided by this Builder card.
*/
private int prestigeValue;
/**
* Returns the reduction value of this Builder card.
* *
* @return Builder specific reduction value * @return the reduction value of this Builder card.
*/ */
public int getReductionValue() { public int getReductionValue() {
return reductionValue; return reductionValue;
} }
/**
* Returns the prestige value of this Builder card.
*
* @return the prestige value of this Builder card.
*/
public int getPrestigeValue() { public int getPrestigeValue() {
return prestigeValue; return prestigeValue;
} }
/**
* Creates a Builder character card with the specified era, reduction value,
* and prestige value.
*
* @param Era the era of the Builder card.
* @param reductionValue the reduction value of the Builder card.
* @param prestigeValue the prestige value of the Builder card.
* @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
*/
public Builder(int Era, int reductionValue, int prestigeValue) throws IllegalArgumentException { public Builder(int Era, int reductionValue, int prestigeValue) throws IllegalArgumentException {
super(Era,CharacterType.BUILDER); super(Era,CharacterType.BUILDER);
if(reductionValue < 0) { if(reductionValue < 0) {
@@ -32,6 +57,16 @@ public class Builder extends Character
this.prestigeValue = prestigeValue; this.prestigeValue = prestigeValue;
} }
/**
* Creates a Builder character card with the specified era, reduction value,
* prestige value, and minimum number of players.
*
* @param Era the era of the Builder card.
* @param reductionValue the reduction value of the Builder card.
* @param prestigeValue the prestige value of the Builder card.
* @param nMin the minimum number of players required for the card.
* @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
*/
public Builder(int Era, int reductionValue, int prestigeValue,int nMin) throws IllegalArgumentException { public Builder(int Era, int reductionValue, int prestigeValue,int nMin) throws IllegalArgumentException {
super(Era,CharacterType.BUILDER,nMin); super(Era,CharacterType.BUILDER,nMin);
if(reductionValue < 0) { if(reductionValue < 0) {
@@ -44,14 +79,30 @@ public class Builder extends Character
} }
this.prestigeValue = prestigeValue; this.prestigeValue = prestigeValue;
} }
/**
* Returns the string representation of this Builder card.
*
* @return the string representation of this Builder card.
*/
@Override @Override
public String toString() { return super.toString()+" Reduction Value: " + String.valueOf(reductionValue) + "\n Prestige Value: " + String.valueOf(prestigeValue); } public String toString() { return super.toString()+" Reduction Value: " + String.valueOf(reductionValue) + "\n Prestige Value: " + String.valueOf(prestigeValue); }
/**
* Creates and returns a copy of this Builder card.
*
* @return a clone of this Builder card.
*/
@Override @Override
public Character clone() { public Character clone() {
return new Builder(getEra(),getReductionValue(), getPrestigeValue(), getNMin()); return new Builder(getEra(),getReductionValue(), getPrestigeValue(), getNMin());
} }
/**
* Inserts this Builder card into the specified player's Builder collection.
*
* @param player the player who receives the card.
*/
public void insert(Player player) { public void insert(Player player) {
player.builders.add(this); player.builders.add(this);
} }
@@ -7,24 +7,49 @@ import it.polimi.ingsw.gc14.Model.Player;
public class Gatherer extends Character { public class Gatherer extends Character {
/** /**
* Creates a Gatherer character card with the specified era.
* *
* @param Era gatherers era * @param Era Gatherers era.
*/ */
public Gatherer(int Era) { public Gatherer(int Era) {
super(Era, CharacterType.GATHERER); super(Era, CharacterType.GATHERER);
} }
/**
* Creates a Gatherer character card with the specified era and minimum number of players.
*
* @param Era the era of the Gatherer card.
* @param nMin the minimum number of players required for the card.
*/
public Gatherer(int Era, int nMin) { public Gatherer(int Era, int nMin) {
super(Era, CharacterType.GATHERER,nMin); super(Era, CharacterType.GATHERER,nMin);
} }
/**
* Returns the string representation of this Gatherer card.
*
* @return the string representation of this Gatherer card.
*/
@Override @Override
public String toString() { public String toString() {
return super.toString(); return super.toString();
} }
/**
* Creates and returns a copy of this Gatherer card.
*
* @return a clone of this Gatherer card.
*/
@Override @Override
public Character clone() { public Character clone() {
return new Gatherer(getEra(), getNMin()); return new Gatherer(getEra(), getNMin());
} }
/**
* Inserts this Gatherer card into the specified player's Gatherer collection.
*
* @param player the player who receives the card.
*/
public void insert(Player player) { public void insert(Player player) {
player.gatherers.add(this); player.gatherers.add(this);
} }
@@ -8,36 +8,63 @@ public class Hunter extends Character {
private boolean icon; private boolean icon;
/** /**
* Returns whether this Hunter card has the icon.
* *
* @return Hunter specific icon * @return {@code true} if this Hunter card has the icon, {@code false} otherwise.
*/ */
public boolean getIcon() { public boolean getIcon() {
return icon; return icon;
} }
/** /**
* Creates a Hunter character card with the specified era and icon value.
* *
* @param Era hunter era * @param Era the era of the Hunter card.
* @param icon hunter icon * @param icon the icon value of the Hunter card.
*/ */
public Hunter(int Era, boolean icon) { public Hunter(int Era, boolean icon) {
super(Era, CharacterType.HUNTER); super(Era, CharacterType.HUNTER);
this.icon = icon; this.icon = icon;
} }
/**
* Creates a Hunter character card with the specified era, icon value,
* and minimum number of players.
*
* @param Era the era of the Hunter card.
* @param icon the icon value of the Hunter card.
* @param nMin the minimum number of players required for the card.
*/
public Hunter(int Era, boolean icon, int nMin) { public Hunter(int Era, boolean icon, int nMin) {
super(Era, CharacterType.HUNTER,nMin); super(Era, CharacterType.HUNTER,nMin);
this.icon = icon; this.icon = icon;
} }
/**
* Returns the string representation of this Hunter card.
*
* @return the string representation of this Hunter card.
*/
@Override @Override
public String toString() { public String toString() {
return super.toString() + "Icon: " + String.valueOf(icon); return super.toString() + "Icon: " + String.valueOf(icon);
} }
/**
* Creates and returns a copy of this Hunter card.
*
* @return a clone of this Hunter card.
*/
@Override @Override
public Character clone() { public Character clone() {
return new Hunter(getEra(), getIcon(), getNMin()); return new Hunter(getEra(), getIcon(), getNMin());
} }
/**
* Inserts this Hunter card into the specified player's Hunter collection.
*
* @param player the player who receives the card.
*/
@Override @Override
public void insert(Player player) { public void insert(Player player) {
player.hunters.add(this); player.hunters.add(this);
@@ -7,18 +7,20 @@ public class Inventor extends Character {
private int icon; private int icon;
/** /**
* Returns the icon value of this Inventor card.
* *
* @return Inventor Specific Symbol * @return the icon value of this Inventor card.
*/ */
public int Icon() { public int Icon() {
return icon; return icon;
} }
/** /**
* Creates an Inventor character card with the specified era and icon value.
* *
* @param Era inventor era * @param Era the era of the Inventor card.
* @param icon inventor symbol * @param icon the icon value of the Inventor card.
* @throws IllegalArgumentException * @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
*/ */
public Inventor(int Era,int icon) throws IllegalArgumentException { public Inventor(int Era,int icon) throws IllegalArgumentException {
super(Era, CharacterType.INVENTOR); super(Era, CharacterType.INVENTOR);
@@ -26,21 +28,48 @@ public class Inventor extends Character {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.icon = icon; this.icon = icon;
} }
/**
* Creates an Inventor character card with the specified era, icon value,
* and minimum number of players.
*
* @param Era the era of the Inventor card.
* @param icon the icon value of the Inventor card.
* @param nMin the minimum number of players required for the card.
* @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
*/
public Inventor(int Era,int icon,int nMin) throws IllegalArgumentException { public Inventor(int Era,int icon,int nMin) throws IllegalArgumentException {
super(Era, CharacterType.INVENTOR,nMin); super(Era, CharacterType.INVENTOR,nMin);
if(icon<0 || icon>9) if(icon<0 || icon>9)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.icon = icon; this.icon = icon;
} }
/**
* Returns the string representation of this Inventor card.
*
* @return the string representation of this Inventor card.
*/
@Override @Override
public String toString() { public String toString() {
return super.toString() + " Symbol:" + String.valueOf(icon); return super.toString() + " Symbol:" + String.valueOf(icon);
} }
/**
* Creates and returns a copy of this Inventor card.
*
* @return a clone of this Inventor card.
*/
@Override @Override
public Character clone() { public Character clone() {
return new Inventor(getEra(),icon, getNMin()); return new Inventor(getEra(),icon, getNMin());
} }
/**
* Inserts this Inventor card into the specified player's Inventor collection.
*
* @param player the player who receives the card.
*/
@Override @Override
public void insert(Player player) { public void insert(Player player) {
player.inventors.add(this); player.inventors.add(this);
@@ -10,36 +10,63 @@ public class Shaman extends Character {
private int icon; private int icon;
/** /**
* Returns the icon value of this Shaman card.
* *
* @return Shaman specific icon * @return the icon value of this Shaman card.
*/ */
public int getIcon() { public int getIcon() {
return icon; return icon;
} }
/** /**
* Creates a Shaman character card with the specified era and icon value.
* *
* @param Era shaman era * @param Era the era of the Shaman card.
* @param icon shaman icon * @param icon the icon value of the Shaman card.
*/ */
public Shaman(int Era, int icon) { public Shaman(int Era, int icon) {
super(Era, CharacterType.SHAMAN); super(Era, CharacterType.SHAMAN);
this.icon = icon; this.icon = icon;
} }
/**
* Creates a Shaman character card with the specified era, icon value,
* and minimum number of players.
*
* @param Era the era of the Shaman card.
* @param icon the icon value of the Shaman card.
* @param nMin the minimum number of players required for the card.
*/
public Shaman(int Era, int icon, int nMin) { public Shaman(int Era, int icon, int nMin) {
super(Era, CharacterType.SHAMAN,nMin); super(Era, CharacterType.SHAMAN,nMin);
this.icon = icon; this.icon = icon;
} }
/**
* Returns the string representation of this Shaman card.
*
* @return the string representation of this Shaman card.
*/
@Override @Override
public String toString() { public String toString() {
return super.toString() + "icon: " + String.valueOf(icon); return super.toString() + "Icon: " + String.valueOf(icon);
} }
/**
* Creates and returns a copy of this Shaman card.
*
* @return a clone of this Shaman card.
*/
@Override @Override
public Character clone() { public Character clone() {
return new Shaman(getEra(), getIcon(), getNMin()); return new Shaman(getEra(), getIcon(), getNMin());
} }
/**
* Inserts this Shaman card into the specified player's Shaman collection.
*
* @param player the player who receives the card.
*/
@Override @Override
public void insert(Player player) public void insert(Player player)
{ {