Package dev.davwheat

Class Animal


  • public class Animal
    extends BoardSpace
    Class that represents an Animal, which is a space on the GameBoard.
    • Constructor Summary

      Constructors 
      Constructor Description
      Animal​(java.lang.String name, double cost, double upgradeCost, double[] stopCosts, int index, Game game)
      Create a new instance of the Animal class.
    • Method Summary

      Modifier and Type Method Description
      AnimalLevel getCurrentLevel()
      Gets the current level of this Animal.
      Player getOwner()
      Gets the owner of this animal
      double getStopCost​(Player actor)
      Get the cost for the provided Player to stop on this Animal's BoardSpace.
      boolean isOwnedBy​(Player actor)
      Tests if the provided Player owns this animal.
      boolean isUpgradable​(Player actor)
      Determines whether the Animal is upgradable by the specified Player.
      void payForStop​(Player actor)
      Charge to provided Player for stopping on this Animal.
      void printCard()
      Prints a visual representation of the card to stdout.
      void purchase​(Player actor)
      Attempts to purchase the Animal and make it owned by the Player.
      void upgrade​(Player actor)
      Attempts to upgrade an Animal to the next level.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • purchaseCost

        public final double purchaseCost
        The cost of the Animal to buy.
      • upgradeCost

        public final double upgradeCost
        The cost to upgrade the Animal to the next level.
      • stopCosts

        public final double[] stopCosts
        The cost to stop on this Animal for each level.

        Contains indexes 0 to 3 (inclusive) for Levels 0 to 3.

    • Constructor Detail

      • Animal

        public Animal​(java.lang.String name,
                      double cost,
                      double upgradeCost,
                      double[] stopCosts,
                      int index,
                      Game game)
        Create a new instance of the Animal class.
        Parameters:
        name - Name of the Animal shown to Players.
        cost - The cost to buy the Animal.
        upgradeCost - The cost to upgrade the Animal.
        stopCosts - An array of 4 costs for stopping on the Animal (Level 0 - 3).
        index - Where the Animal is on the GameBoard.
        game - The instance of Game that this Animal belongs to.
    • Method Detail

      • getOwner

        public Player getOwner()
        Gets the owner of this animal
        Returns:
        Animal's owner
      • getStopCost

        public double getStopCost​(Player actor)
        Get the cost for the provided Player to stop on this Animal's BoardSpace.
        Parameters:
        actor - The player
        Returns:
        The cost for this player to stop on this animal
      • isUpgradable

        public boolean isUpgradable​(Player actor)
        Determines whether the Animal is upgradable by the specified Player.
        Parameters:
        actor - Player attempting the upgrade
        Returns:
        Whether the Player can upgrade the Animal
      • isOwnedBy

        public boolean isOwnedBy​(Player actor)
        Tests if the provided Player owns this animal.
        Parameters:
        actor - The player
        Returns:
        If the player owns the animal
      • printCard

        public void printCard()
        Prints a visual representation of the card to stdout.
      • getCurrentLevel

        public AnimalLevel getCurrentLevel()
        Gets the current level of this Animal.
        Returns:
        the level