Class Country

java.lang.Object
org.bitsquad.warzone.country.Country

public class Country extends Object
Represents a country object. This class defines a country with its ID, list of neighbors and other relevant details according to system design.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default Constructor
    Country(int p_countryId, int p_continentId)
    Parameterized constructor
    Country(int p_countryId, int p_continentId, String p_countryName, int p_armyValue, int p_ownedByPlayerId, ArrayList<Integer> p_neighbors)
    Parameterized constructor
    Country(int p_countryId, String p_countryName, int p_continentId)
    Parameterized constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addNeighbor(int p_neighborCountryId)
    addNeighbor method add the id of the neighbor country in the neighbors list.
    boolean
    equals(Object l_obj)
    Used to check for equality
    int
    Getter method for Army Value.
    int
    Getter method of continent Id.
    int
    Getter method for the Country Id.
    Getter method for the Country Name.
    This getter method use to get the list of neighbor Countries.
    int
    This getter method use to get the player id who owns the country.
    int
    Hashcode
    boolean
    removeNeighbor(int p_neighborCountryId)
    removeNeighbor method remove the id of the neighbor country from the neighbors list.
    void
    setArmyValue(int p_armyValue)
    Setter method of Army Value.
    void
    setContinentId(int p_continentId)
    Setter method of continentId which set the continent id.
    void
    setCountryId(int p_countryId)
    Setter method for the Country Id.
    void
    setCountryName(String p_countryName)
    Setter method for the Country Name
    void
    This method use to set the list of neighbor countries.
    void
    setOwnedByPlayerId(int p_ownedByPlayerId)
    This setter method use to set the Player Id who owns the country.
    ToString method

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Country

      public Country()
      Default Constructor
    • Country

      public Country(int p_countryId, int p_continentId)
      Parameterized constructor
      Parameters:
      p_countryId - country ID
      p_continentId - continent ID
    • Country

      public Country(int p_countryId, String p_countryName, int p_continentId)
      Parameterized constructor
      Parameters:
      p_countryId - Country ID
      p_countryName - Country Name
      p_continentId - Continent ID
    • Country

      public Country(int p_countryId, int p_continentId, String p_countryName, int p_armyValue, int p_ownedByPlayerId, ArrayList<Integer> p_neighbors)
      Parameterized constructor
      Parameters:
      p_countryId - country ID
      p_continentId - continent ID
      p_countryName - country name
      p_armyValue - the number of army units present in a country
      p_neighbors - the neighbors of a country
      p_ownedByPlayerId - the playerid of the owner of the country
  • Method Details

    • toString

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

      public int hashCode()
      Hashcode
      Overrides:
      hashCode in class Object
      Returns:
      hashcode for the object
    • equals

      public boolean equals(Object l_obj)
      Used to check for equality
      Overrides:
      equals in class Object
      Parameters:
      l_obj - object ot be compared to
      Returns:
      true if the objects are equal
    • getCountryId

      public int getCountryId()
      Getter method for the Country Id.
      Returns:
      the id of the country
    • setCountryId

      public void setCountryId(int p_countryId)
      Setter method for the Country Id.
      Parameters:
      p_countryId - the id of country.
    • getCountryName

      public String getCountryName()
      Getter method for the Country Name.
      Returns:
      the country name.
    • setCountryName

      public void setCountryName(String p_countryName)
      Setter method for the Country Name
      Parameters:
      p_countryName - the Country name
    • getArmyValue

      public int getArmyValue()
      Getter method for Army Value.
      Returns:
      the number of Armies allocated to the country.
    • setArmyValue

      public void setArmyValue(int p_armyValue)
      Setter method of Army Value.
      Parameters:
      p_armyValue - the number of Country's Armies.
    • getContinentId

      public int getContinentId()
      Getter method of continent Id.
      Returns:
      the continent id.
    • setContinentId

      public void setContinentId(int p_continentId)
      Setter method of continentId which set the continent id.
      Parameters:
      p_continentId - the continent id.
    • getOwnedByPlayerId

      public int getOwnedByPlayerId()
      This getter method use to get the player id who owns the country.
      Returns:
      the player id.
    • setOwnedByPlayerId

      public void setOwnedByPlayerId(int p_ownedByPlayerId)
      This setter method use to set the Player Id who owns the country.
      Parameters:
      p_ownedByPlayerId - the Owned player id.
    • getNeighbors

      public ArrayList<Integer> getNeighbors()
      This getter method use to get the list of neighbor Countries.
      Returns:
      the ArrayList of neighbor Countries
    • setNeighbors

      public void setNeighbors(ArrayList<Integer> p_neighbors)
      This method use to set the list of neighbor countries.
      Parameters:
      p_neighbors - the integer ArrayList of neighbor countries's Id.
    • addNeighbor

      public boolean addNeighbor(int p_neighborCountryId)
      addNeighbor method add the id of the neighbor country in the neighbors list.
      Parameters:
      p_neighborCountryId - the id of the neighbor.
      Returns:
      true if the condition is true otherwise false
    • removeNeighbor

      public boolean removeNeighbor(int p_neighborCountryId)
      removeNeighbor method remove the id of the neighbor country from the neighbors list.
      Parameters:
      p_neighborCountryId - the id of the neighbor country.
      Returns:
      true if the condition is true otherwise false