Class CareTaker

java.lang.Object
com.deco2800.game.memento.CareTaker

public class CareTaker extends Object
the caretaker object records and stores the player state into the internal memory for the engine to retrieve in the future A combination of singleton and memento design pattern, which allows memento to be retrieved from anywhere in the game and restrict it to only having one instance, hence preventing duplication of memento and allows better management
  • Constructor Details

    • CareTaker

      public CareTaker()
  • Method Details

    • getInstance

      public static CareTaker getInstance()
    • deleteAll

      public static void deleteAll()
    • add

      public void add(Memento state)
      adds the selected memento into the caretaker
      Parameters:
      state - - the memento to be stored
    • getLast

      public Memento getLast()
      retrieve the last memento saved
      Returns:
      - the last memento
    • size

      public int size()
      retrieve the entire list of the caretaker
      Returns:
      - the list of the previously saved memento