Package org.bitsquad.warzone.country
Class Country
java.lang.Object
org.bitsquad.warzone.country.Country
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
ConstructorsConstructorDescriptionCountry()
Default ConstructorCountry
(int p_countryId, int p_continentId) Parameterized constructorCountry
(int p_countryId, int p_continentId, String p_countryName, int p_armyValue, int p_ownedByPlayerId, ArrayList<Integer> p_neighbors) Parameterized constructorParameterized constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
addNeighbor
(int p_neighborCountryId) addNeighbor method add the id of the neighbor country in the neighbors list.boolean
Used to check for equalityint
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()
Hashcodeboolean
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 Namevoid
setNeighbors
(ArrayList<Integer> p_neighbors) 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()
ToString method
-
Constructor Details
-
Country
public Country()Default Constructor -
Country
public Country(int p_countryId, int p_continentId) Parameterized constructor- Parameters:
p_countryId
- country IDp_continentId
- continent ID
-
Country
Parameterized constructor- Parameters:
p_countryId
- Country IDp_countryName
- Country Namep_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 IDp_continentId
- continent IDp_countryName
- country namep_armyValue
- the number of army units present in a countryp_neighbors
- the neighbors of a countryp_ownedByPlayerId
- the playerid of the owner of the country
-
-
Method Details
-
toString
ToString method -
hashCode
public int hashCode()Hashcode -
equals
Used to check for equality -
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
Getter method for the Country Name.- Returns:
- the country name.
-
setCountryName
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
This getter method use to get the list of neighbor Countries.- Returns:
- the ArrayList of neighbor Countries
-
setNeighbors
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
-