Class Order

java.lang.Object
org.bitsquad.warzone.order.Order
Direct Known Subclasses:
AdvanceOrder, AirliftOrder, BlockadeOrder, BombOrder, DeployOrder, NegotiateOrder

public abstract class Order extends Object
Represents an order placed by a player This class defines the order placed with the ID of the player, the source and target countries, the number of army units involved in the order and the type of the action as per game-play actions. It acts as an intermediate to the GameOrder Interface by adding necessary functionality. All other Orders extend this class, it acts as the Command Interface for the Command Pattern
  • Field Details

    • d_playerInstance

      protected BasePlayer d_playerInstance
  • Constructor Details

    • Order

      public Order(BasePlayer p_player, int p_sourceCountryId, int p_targetCountryId, int p_noOfArmyUnits)
      Parametrized Constructor Order
      Parameters:
      p_player - Instance of the player
      p_sourceCountryId - Source Country ID
      p_targetCountryId - Target Country ID
      p_noOfArmyUnits - No of Army Units
  • Method Details

    • toString

      public String toString()
      toString method
      Overrides:
      toString in class Object
      Returns:
      string representation of class
    • getPlayer

      public BasePlayer getPlayer()
      Getter for Player
      Returns:
      Returns the player instance
    • setSourceCountryId

      public void setSourceCountryId(int p_sourceCountryId)
      Setter for source country Id
      Parameters:
      p_sourceCountryId - Setting the source country Id
    • getSourceCountryId

      public int getSourceCountryId()
      Getter for source country Id
      Returns:
      Returns the source country Id
    • setTargetCountryId

      public void setTargetCountryId(int p_targetCountryId)
      Setter method for target country Id
      Parameters:
      p_targetCountryId - Setting the target country Id
    • getTargetCountryId

      public int getTargetCountryId()
      Getter method for target country Id
      Returns:
      Returns the target country Id
    • setNoOfArmyUnits

      public void setNoOfArmyUnits(int p_noOfArmyUnits)
      Setter method for number of army units
      Parameters:
      p_noOfArmyUnits - Setting the number of army units
    • getNoOfArmyUnits

      public int getNoOfArmyUnits()
      Getter method for number of army units involved
      Returns:
      Returns the number of army units involved
    • isValid

      public abstract boolean isValid()
      Checks if a particular method is valid or not
      Returns:
      boolean
    • execute

      void execute()