package it.polimi.ingsw.gc14.Model; import java.io.Serializable; /** * Represents a slot with a specific identifier and associated values * for upper cards, lower cards, food, and minimum number of players. * The slot configuration depends on the specified slot identifier. */ public class Slot implements Serializable { // Getters /** * The identifier of this slot. */ private char slotId; /** * Returns the identifier of this slot. * * @return the identifier of this slot. */ public char getSlotId() { return slotId; } /** * The number of upper cards associated with this slot. */ private int NUpper; /** * Returns the number of upper cards associated with this slot. * * @return the number of upper cards associated with this slot. */ public int getNUpper(){ return NUpper; } /** * The minimum number of players required for this slot. */ private int nMinPlayer; /** * Returns the minimum number of players required for this slot. * * @return the minimum number of players required for this slot. */ public int getNMinPlayer() { return nMinPlayer; } /** * The number of lower cards associated with this slot. */ private int NLower; /** * Returns the number of lower cards associated with this slot. * * @return the number of lower cards associated with this slot. */ public int getNLower(){ return NLower; } /** * The amount of Food associated with this slot. */ private int Food; /** * Returns the amount of Food associated with this slot. * * @return the amount of Food associated with this slot. */ public int getFood(){ return Food; } // End getters // Setters // End setters // Constructors /** * Creates a slot with the specified identifier. * The slot values for Food, NLower, NUpper, and minimum number of players * are determined by the given slot identifier. * * @param slotId the identifier of the slot. * @throws IllegalArgumentException if the specified slot identifier is not valid. */ public Slot(char slotId) throws IllegalArgumentException { this.slotId = slotId; this.nMinPlayer=0; switch(slotId) { case 'A': this.Food = 3; this.NLower = 0; this.NUpper = 0; this.nMinPlayer=5; break; case 'B': this.Food = 0; this.NLower = 1; this.NUpper = 0; break; case 'C': this.Food = 0; this.NLower = 0; this.NUpper = 1; break; case 'D': this.Food = 0; this.NLower = 2; this.NUpper = 0; this.nMinPlayer = 3; break; case 'E': this.Food = 0; this.NLower = 1; this.NUpper = 1; break; case 'F': this.Food = 0; this.NLower = 0; this.NUpper = 2; break; case 'G': this.Food = 0; this.NLower = 1; this.NUpper = 2; this.nMinPlayer = 4; break; default: throw new IllegalArgumentException(); } } /** * Returns the string representation of this slot. * The returned string includes the slot identifier, number of upper cards, * number of lower cards, food value, and minimum number of players. * * @return the string representation of this slot. */ @Override public String toString() { return ("SlotID: "+this.getSlotId()+"\nNUpper: "+this.getNUpper()+"\nNLower: "+this.getNLower()+"\nFood: "+this.getFood()+"\n"); } /** * Prints a string representation of this {@code Slot}. This specific variation is used in the {@code Game}'s * toString to print a more detailed version for the TUI implementation. *
includes: *