Coverage Summary for Class: PlayableCard (it.polimi.ingsw.gc14.Model)

Class Class, % Method, % Branch, % Line, %
PlayableCard 100% (1/1) 100% (4/4) 100% (8/8) 100% (12/12)


 package it.polimi.ingsw.gc14.Model;
 import java.io.Serializable;
 
 
 /**
  * Abstract base class for all playable cards.
  * A PlayableCard is characterized by an era value.
  */
 public abstract class PlayableCard implements Serializable {
 
     /**
      * The image identifier of the playable card.
      */
     private final String idIMG;
 
     /**
      * Returns the image identifier of this playable card.
      *
      * @return the image identifier of this playable card.
      */
     public String getIdIMG() {
         return idIMG;
     }
 
     /**
      * The era associated with this playable card.
      */
     private final int era;
 
     /**
      * Returns the era of this playable card.
      *
      * @return the era of this playable card.
      */
     public int getEra(){
         return era;
     }
 
     /**
      * Creates a playable card with the specified era.
      *
      * @param era the era of the playable card.
      * @throws IllegalArgumentException if {@code era <= 0} or {@code era >= 4}.
      */
     public PlayableCard(int era) throws IllegalArgumentException {
         idIMG = "-1";
         if (era > 0 && era < 4) {
             this.era = era;
         } else {
             throw new IllegalArgumentException();
         }
     }
 
     /**
      * Creates a playable card with the specified image id and era.
      *
      * @param idIMG the image identifier of the playable card.
      * @param era the era of the playable card.
      * @throws IllegalArgumentException if {@code era <= 0} or {@code era >= 4}.
      */
     public PlayableCard(String idIMG, int era) throws IllegalArgumentException {
         this.idIMG = idIMG;
         if (era > 0 && era < 4) {
             this.era = era;
         } else {
             throw new IllegalArgumentException();
         }
     }
 
     /**
      * Returns the compact representation shown in the player hand panel.
      *
      * @return the player-hand string representation of this card.
      */
     public abstract String toStringPlayer();
 
     /**
      * Returns the representation shown on the board (offer track cards).
      *
      * @return the board string representation of this card.
      */
     public abstract String toStringBoard();
 }