Midterm-v2-solution

Execute typemodelremovefromparent 5 2 public void

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ss RemoveTypeCommand extends Command implements ICommand { private TypeModel _typeModel; 9 public RemoveTypeCommand() { super(); _typeModel = new NullTypeModel(); } 7 3 public RemoveTypeCommand(TypeModel model) { super(); _typeModel = model; 10 } public void setTypeModel(TypeModel model) { _typeModel = model; } public TypeModel getTypeModel() { return _typeModel; } public void execute() { super.execute(); _typeModel.removeFromParent(); } 5 2 public void undo() { if (_typeModel.isNotNull()) { RootModel root = _typeModel.getParent(); TypeModel newTypeModel; newTypeModel = root.createTypeModel(_typeModel.getType()); newTypeModel.setLocation(_typeModel.getLocation()); _typeModel = newTypeModel; root.updateRelationships(); } } } public void redo() { execute(); } 2 1 4, 8 [ CSE116 – MIDTERM EXAM, VERSION 2] SPRING 2010 Question 2 [10 marks] Consider the problem of implementing a simple four ­function calculator. Suppose we want this calculator to support computing the re...
View Full Document

This note was uploaded on 08/19/2013 for the course CSE 1156 taught by Professor Alhonce during the Fall '11 term at SUNY Buffalo.

Ask a homework question - tutors are online