Package pp.battleship

Klasse BattleshipConfig

java.lang.Object
pp.util.config.Config
pp.battleship.BattleshipConfig
Bekannte direkte Unterklassen:
BattleshipClientConfig

public class BattleshipConfig extends pp.util.config.Config
Provides access to the configuration settings for the Battleship game.

This class allows for loading configuration settings from a properties file, including the server port, map dimensions, and the number of ships of various lengths.

Note: Attributes of this class are not marked as final to allow for proper initialization when reading from a properties file.

  • Verschachtelte Klassen - Übersicht

    Von Klasse geerbte verschachtelte Klassen/Schnittstellen pp.util.config.Config

    pp.util.config.Config.Property, pp.util.config.Config.Separator
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    Creates an instance of BattleshipConfig with default settings.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    int
    Returns the height of the game map.
    int
    Returns the width of the game map.
    int
    Returns the port number configured for the Battleship server.
    Returns a map representing the number of ships for each length.

    Von Klasse geerbte Methoden pp.util.config.Config

    convertToType, readFrom, readFrom, readFromIfExists, toString

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Konstruktordetails

    • BattleshipConfig

      public BattleshipConfig()
      Creates an instance of BattleshipConfig with default settings.
  • Methodendetails

    • getPort

      public int getPort()
      Returns the port number configured for the Battleship server.
      Gibt zurück:
      the port number
    • getMapWidth

      public int getMapWidth()
      Returns the width of the game map. The width is guaranteed to be at least 2 units.
      Gibt zurück:
      the width of the game map
    • getMapHeight

      public int getMapHeight()
      Returns the height of the game map. The height is guaranteed to be at least 2 units.
      Gibt zurück:
      the height of the game map
    • getShipNums

      public Map<Integer,Integer> getShipNums()
      Returns a map representing the number of ships for each length. The keys are ship lengths, and the values are the corresponding number of ships.
      Gibt zurück:
      a map of ship lengths to the number of ships