Class Caretaker

java.lang.Object
  |
  +--Caretaker

public class Caretaker
extends java.lang.Object
implements java.awt.event.ActionListener

This class handles button clicks to save/restore snapshots. This class also serves as a caretaker of a snapshot of the Othello's board.


Constructor Summary
Caretaker(Board board)
          Construct this ActionListener of the save and restore buttons and caretaker of the board snapshot.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          The action performed by the ActionListener.
 Board.Snapshot load()
          Load and return a saved snapshot of a board of Othello.
 void save(Board.Snapshot state)
          Save a snapshot of a board of Othello.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Caretaker

public Caretaker(Board board)
Construct this ActionListener of the save and restore buttons and caretaker of the board snapshot. An attempt to restore a board that was never saved results in a message printed on standard error.
Parameters:
board - The board of the game of Othello.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
The action performed by the ActionListener. Either save or restore the board.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The action event this listener listens to.

load

public Board.Snapshot load()
Load and return a saved snapshot of a board of Othello.
Returns:
The saved snapshot.

save

public void save(Board.Snapshot state)
Save a snapshot of a board of Othello.
Parameters:
object - The snapshot to be saved.