Class Caretaker

java.lang.Object
Behavioral.Memento.Caretaker

public class Caretaker extends Object
The Caretaker class manages Memento objects.
  • Constructor Details

    • Caretaker

      public Caretaker()
      Default constructor for Caretaker.
  • Method Details

    • addMemento

      public void addMemento(Memento memento)
      Adds a Memento to the list.
      Parameters:
      memento - The Memento to add.
    • getMemento

      public Memento getMemento(int index)
      Retrieves a Memento by index.
      Parameters:
      index - The index of the desired Memento.
      Returns:
      The Memento at the specified index.
      Throws:
      IndexOutOfBoundsException - if the index is invalid.