Class FILEHelper

java.lang.Object
it.polimi.ingsw.controller.FILEHelper

public class FILEHelper extends Object
helper class for reading and writing txt file, useful for persistence
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    check if there is a cache server from a previous game
    static Game
    load the current state of the server from the file server.txt
    static void
    write 'FAIL' on status.txt indicating tha the server closed in a NOT normal way
    static void
    writeServer(Game server)
    save the current state of the server in the file server.txt
    static void
    write 'SUCC' on status.txt indicating tha the server closed in a normal way

    Methods inherited from class java.lang.Object

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

    • FILEHelper

      public FILEHelper()
  • Method Details

    • writeSucc

      public static void writeSucc()
      write 'SUCC' on status.txt indicating tha the server closed in a normal way
    • writeFail

      public static void writeFail()
      write 'FAIL' on status.txt indicating tha the server closed in a NOT normal way
    • havaCachedServer

      public static boolean havaCachedServer()
      check if there is a cache server from a previous game
      Returns:
      true iff there is a cached server
    • writeServer

      public static void writeServer(Game server)
      save the current state of the server in the file server.txt
      Parameters:
      server - the current server that will be saved
    • loadServer

      public static Game loadServer()
      load the current state of the server from the file server.txt
      Returns:
      the state of the old server that was saved (Game Object)