Module Design - Undo Object

Last update April 4 at 8:25 p.m.

This object was designed by Dave Sager

Object Overview:

The undo object is used to return the program to its previous state. If the user enters a command into the "Command to be exectued" field and then realize after running that command that it was a mistake, they can undo the command. By undoing the command they return the state of the program to the state just before there last entered command was executed. This is done by making "deep" copies of the three master objects. These copies are made when the user hits the enter button after typing a command. Then if the user chooses undo the program will revert itself back to the "deep" copied states of the master objects.

Private Data:

The MasterNode oldMNO is used to store a "deep copy" of the state of the MasterNode object before the most recent update. The MasterLink oldMLkO is used to store a "deep copy" of the state of the MasterLink object before the most recent update. The MasterLine oldMLnO is used to store a "deep copy" of the state of the MasterLine object before the most recent update.

 

Methods:

public void Undo()
Overview: Replaces the master node, link, and line objects with the Old versions, then tells them to draw themselves. The replaced objects are derferenced by this and will automatically be cleaned up by Java.
Parameters: None.
Pre-conditions: Undo must be enabled in the menu.
Post-conditions: Restores the last saved state of the progam and calls the re-draw on each object.
Algorithm: All existing Node, Link, Line, MasterNode, MasterLink , and MasterLine objects are de-refereneced and "oldMNO", "oldMLkO" and "oldMLnO" are "deep" copied into there place. After the "deep" copy these objects are cleared (all variables/objects within these are re-intialized to NULL). Then the calls the method GetTextInProgress it figures out if this thing returned contains one line of code or a loop. If it contains one line of code then the method GetTextExecuted() and then makes a new string that contains what was returned from the method call concatinated with "//" and what was returned from GetTextInProgress. If it contains a loop then it follows the same process but adds "/*\N" before what was retunred by GetTextInProgress and then "*/ \N" after it. There also needs to be some way to handle indention if it is a loop.
Interaction with other objects: None.
Error Conditions: None
Return Value: None

public void Update()
Overview: Copies the master node, link, and line objects, and updates the pointers in the undo object so that the next instruction can be executed.
Parameters: None.
Pre-conditions: None.
Post-conditions: Stores a new value into the Undo variables for use with the undo() command.
Algorithm: The MasterNode, MasterLink, and MasterLine objects are "deep" copied into "oldMNO", "oldMLkO" and "oldMLnO" respectively.
Interaction with other objects: None.
Error Conditions: None
Return Value: None

 

Search engine sitemap created by AutoSitemap.com