Klasse ShipMapDTO

java.lang.Object
pp.battleship.model.dto.ShipMapDTO

public class ShipMapDTO extends Object
A class representing data transfer objects of ship maps for JSON serialization and deserialization.
  • Konstruktordetails

    • ShipMapDTO

      public ShipMapDTO(ShipMap map)
      Constructs a ShipMapDTO object from a ShipMap object.
      Parameter:
      map - the ShipMap object to be converted
  • Methodendetails

    • fits

      public boolean fits(GameDetails details)
      Checks if the current ship map fits the game details provided.
      Parameter:
      details - the game details to be matched against
      Gibt zurück:
      true if the ship map fits the game details, false otherwise
    • getShips

      public List<Battleship> getShips()
      Returns the ships stored in this DTO.
      Gibt zurück:
      the ships stored in this DTO
    • saveTo

      public void saveTo(File file) throws IOException
      Saves the current ShipMapDTO to a file in JSON format.
      Parameter:
      file - the file to which the ShipMapDTO will be saved
      Löst aus:
      IOException - if an I/O error occurs
    • loadFrom

      public static ShipMapDTO loadFrom(File file) throws IOException
      Loads a ShipMapDTO from a file containing JSON data.
      Parameter:
      file - the file from which the ShipMapDTO will be loaded
      Gibt zurück:
      the loaded ShipMapDTO object
      Löst aus:
      IOException - if an I/O error occurs or if the JSON is invalid