Class Adapter

java.lang.Object
org.bitsquad.warzone.map.Map
org.bitsquad.warzone.map.Adapter

public class Adapter extends Map
The Adapter class extends the Map class and adapts the functionality of the ConquestMap class.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Adapter(ConquestMap p_conquestMap)
    Constructs an Adapter object with a ConquestMap instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addContinent(int p_continentId, int p_bonusValue)
    Adds a continent with the specified ID and bonus value to the adapted ConquestMap.
    boolean
    addCountry(int p_countryId, int p_continentId)
    Adds a country with the specified ID to the adapted ConquestMap.
    boolean
    addNeighbor(int p_sourceCountryId, int p_destinationCountryId)
    Adds a neighbor relationship between two countries in the adapted ConquestMap.
    void
    editMap(String p_fileName)
    Edits the map by loading it from the specified file using the adapted ConquestMap.
    Gets the continents from the adapted ConquestMap.
    boolean
    loadMap(String p_fileName)
    Loads a map from the specified file using the adapted ConquestMap.
    boolean
    removeContinent(int p_continentId)
    Removes the continent with the specified ID from the adapted ConquestMap.
    void
    removeCountry(int p_countryId)
    Removes the country with the specified ID from the adapted ConquestMap.
    void
    removeNeighbor(int p_sourceCountryId, int p_destinationCountryId)
    Removes a neighbor relationship between two countries in the adapted ConquestMap.
    void
    saveMap(String p_fileName)
    Saves the map to a file with the specified name using the adapted ConquestMap.
    boolean
    Validates the current state of the map using the adapted ConquestMap.
    void
    Visualizes the graph representation of the map using the adapted ConquestMap.

    Methods inherited from class org.bitsquad.warzone.map.Map

    addContinent, addCountry, getContinent, isContinentSubgraph

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Adapter

      public Adapter(ConquestMap p_conquestMap)
      Constructs an Adapter object with a ConquestMap instance.
      Parameters:
      p_conquestMap - The ConquestMap instance to be adapted.
  • Method Details

    • getContinents

      public HashMap<Integer,Continent> getContinents()
      Gets the continents from the adapted ConquestMap.
      Overrides:
      getContinents in class Map
      Returns:
      HashMap containing continent IDs and corresponding Continent objects.
    • addContinent

      public void addContinent(int p_continentId, int p_bonusValue)
      Adds a continent with the specified ID and bonus value to the adapted ConquestMap.
      Overrides:
      addContinent in class Map
      Parameters:
      p_continentId - The ID of the continent.
      p_bonusValue - The bonus value of the continent.
    • removeContinent

      public boolean removeContinent(int p_continentId)
      Removes the continent with the specified ID from the adapted ConquestMap.
      Overrides:
      removeContinent in class Map
      Parameters:
      p_continentId - The ID of the continent to be removed.
      Returns:
      True if the continent is successfully removed, false otherwise.
    • addCountry

      public boolean addCountry(int p_countryId, int p_continentId)
      Adds a country with the specified ID to the adapted ConquestMap.
      Overrides:
      addCountry in class Map
      Parameters:
      p_countryId - The ID of the country.
      p_continentId - The ID of the continent.
      Returns:
      True if the country is successfully added, false otherwise.
    • removeCountry

      public void removeCountry(int p_countryId)
      Removes the country with the specified ID from the adapted ConquestMap.
      Overrides:
      removeCountry in class Map
      Parameters:
      p_countryId - The ID of the country to be removed.
    • addNeighbor

      public boolean addNeighbor(int p_sourceCountryId, int p_destinationCountryId)
      Adds a neighbor relationship between two countries in the adapted ConquestMap.
      Overrides:
      addNeighbor in class Map
      Parameters:
      p_sourceCountryId - The ID of the source country.
      p_destinationCountryId - The ID of the destination country.
      Returns:
      True if the neighbor relationship is successfully added, false otherwise.
    • removeNeighbor

      public void removeNeighbor(int p_sourceCountryId, int p_destinationCountryId)
      Removes a neighbor relationship between two countries in the adapted ConquestMap.
      Overrides:
      removeNeighbor in class Map
      Parameters:
      p_sourceCountryId - The ID of the source country.
      p_destinationCountryId - The ID of the destination country.
    • loadMap

      public boolean loadMap(String p_fileName)
      Loads a map from the specified file using the adapted ConquestMap.
      Overrides:
      loadMap in class Map
      Parameters:
      p_fileName - The name of the map file.
      Returns:
      True if the map is successfully loaded, false otherwise.
    • saveMap

      public void saveMap(String p_fileName) throws Exception
      Saves the map to a file with the specified name using the adapted ConquestMap.
      Overrides:
      saveMap in class Map
      Parameters:
      p_fileName - The name of the map file (without extension).
      Throws:
      Exception - If the map is invalid and cannot be saved.
    • editMap

      public void editMap(String p_fileName)
      Edits the map by loading it from the specified file using the adapted ConquestMap.
      Overrides:
      editMap in class Map
      Parameters:
      p_fileName - The name of the map file.
    • visualizeGraph

      public void visualizeGraph()
      Visualizes the graph representation of the map using the adapted ConquestMap.
      Overrides:
      visualizeGraph in class Map
    • validateMap

      public boolean validateMap()
      Validates the current state of the map using the adapted ConquestMap.
      Overrides:
      validateMap in class Map
      Returns:
      True if the map is valid, false otherwise.