@Override public PreviousCalculationToCareTaker backupLastCalculation(){ // create a memento object used for restoring two numbers returnnew PreviousCalculationImp(firstNumber, secondNumber); }
/** * Memento Interface to Originator * * This interface allows the originator to restore its state */ publicinterfacePreviousCalculationToOriginator{ intgetFirstNumber(); intgetSecondNumber(); }
1 2 3 4 5 6
/** * Memento interface to CalculatorOperator (Caretaker) */ publicinterfacePreviousCalculationToCareTaker{ // no operations permitted for the caretaker }
/** * Memento Object Implementation * <p> * Note that this object implements both interfaces to Originator and CareTaker */ publicclassPreviousCalculationImpimplementsPreviousCalculationToCareTaker, PreviousCalculationToOriginator{