-------------------------------------------------------------------------- Software Design and Development Winter 1996 COM 1205 --------------------------------------------------------------------------- Final - Answer Form YOUR NAME: Final - Answer Form YOUR NAME: Question 1: ================================================== UNKNOWN1 = W = B E X. UNKNOWN2 = B = L. UNKNOWN3 = E = . UNKNOWN4 = N = X L . UNKNOWN5 = Y = . UNKNOWN6 = Z = . UNKNOWN7 = L : E | N. (CHOICE: any order) UNKNOWN8 = X : Y | Z | W. (CHOICE: any order) Question 2: ================================================== UNKNOWN1 = Graph = Vertex_List. UNKNOWN2 = Vertex : AVertex | BVertex *common* VertexName Mark [ DftNumber] [ AuxVertex_List] [ AuxVertex_List]. UNKNOWN3 = VertexName = DemIdent. UNKNOWN4 = Mark : Marked | Unmarked. UNKNOWN5 = AVertex = . UNKNOWN6 = BVertex = . UNKNOWN7 = AuxVertex = Vertex. UNKNOWN8 = Marked = . UNKNOWN9 = Unmarked = . UNKNOWN10 = AuxVertex_List ~ {AuxVertex} . UNKNOWN11 = Vertex_List ~ {Vertex} . UNKNOWN12 = *operation* void link_graph(Graph* g) *traverse* *from* Graph *to-stop* Vertex *wrapper* Vertex (@ cout << " linking " << this->get_n() << " now " << endl; this -> link_vertex(g); @) CHOICE: *from* Graph *bypassing* ->Vertex,*,*, =>Vertex,* *to* Vertex UNKNOWN13 = *operation* void link_vertex(Graph* g) *traverse* *from* Vertex *to-stop* AuxVertex *wrapper* AuxVertex (@ this -> set_vertex(g->find(this->get_vertex()->get_n())); @) CHOICE: Use bypassing instead of to-stop UNKNOWN14 = *operation* Vertex* find(VertexName* vn) *traverse* *from* Graph *to-stop* Vertex *wrapper* Vertex (@ if (this->get_n()->g_equal(vn)) { cout << " found " << this -> get_n() << endl; return_val = this;}; @) CHOICE: Use bypassing instead of to-stop UNKNOWN15 = *operation* void init () *traverse* *from* Graph *to-stop* Vertex *wrapper* Vertex (@ this -> set_marked(new Unmarked()); @) CHOICE: Use bypassing instead of to-stop UNKNOWN16 = *operation* void dft() *traverse* *from* Graph *to* Vertex *wrapper* Graph (@ this->init(); @) *wrapper* Vertex *prefix* (@ if (this->is_unmarked()){ set_marked(new Marked()); cout << " Vertex " << this->get_n() << " visited " << endl; @) *suffix* (@ }; @) CHOICE: since the propagation graph is cyclic, we can go to any vertex in the cycle. Instead of *from* Graph *to* Vertex we can use: (although this would make the program harder to understand!) *from* Graph *to* AVertex *from* Graph *to* BVertex *from* Graph *to* AuxVertex_List *from* Graph *to* AuxVertex UNKNOWN17 = The Visitor Pattern uses traversals and visitors to express behavior. The traversals were given in succinct form in the unknowns preceding this one. The visitors are the wrappers given in those unknowns. Question 3: ================================================== UNKNOWN1 = Directive = "'from'" Vertex Condition_List "'to'" GenVertex_CList. UNKNOWN2 = GenVertex : Vertex | WildCard. UNKNOWN3 Vertex = DemIdent. UNKNOWN4 = WildCard = "*". UNKNOWN5 = Condition : Inclusion | Exclusion *common* [ EdgeTail_AList] "'at'" GenVertex. UNKNOWN6 = Inclusion = "'include'". UNKNOWN7 = Exclusion = "'exclude'". UNKNOWN8 = EdgeTail : Constr | Alternation *common* GenVertex. UNKNOWN9 = Constr = "->" LabelName "," . UNKNOWN10 = Alternation = "=>" . UNKNOWN11 = LabelName = DemIdent. UNKNOWN12 = // this unknown should not be here Directive_List ~ {Directive}. UNKNOWN13 = Condition_List ~ {Condition}. UNKNOWN14 = GenVertex_CList ~ "{" {GenVertex} "}". UNKNOWN15 = EdgeTail_AList ~ EdgeTail {"'and'" EdgeTail}. UNKNOWN16 = *operation* void print_condition_vertex() *traverse* *from* Directive *via* Condition* *to* Vertex *wrapper* Vertex (@ cout << this; @) Question 4: ================================================== UNKNOWN1 [$variablename methodName: $param1 $param2] example: set retval [$aGraph cppCreAEdge: $ID1 $ID2] UNKNOWN2 Use the object tclexec and the overloaded left shift operator to have Tcl execute commands. tclexec << "Any Tcl command"; Example: #include "tclexec.h" ... *wrapper* Y (@ tclexec << "puts \"me too\" "; @)