-------------------------------------------------------------------------- Software Design and Development Fall 1993 COM 1205 --------------------------------------------------------------------------- Final 280 points total QUESTION 1: 45 UNKNOWNs, 2 points each: 90 points QUESTION 2: 40 UNKNOWNs, 2 points each: 80 points QUESTION 3: 62 UNKNOWNs, 1 point each: 62 points QUESTION 4: 24 UNKNOWNs, 2 points each: 48 points --------------------------------------------------------------------------- Open book and open notes. To make the grading easier, please put your values for the unknowns on the enclosed answer sheet. THE GAME OF REDUNDANCY AND UNKNOWNS ----------------------------------- Most of the questions in this exam ask you to determine unknowns of the form UNKNOWN1, UNKNOWN2, ... This makes it easier for you to answer the questions, since you get extra context information. Yet you need to master the behavioral objectives of the course to answer the questions. Guessing an answer is not a successful strategy and therefore a "game of redundancy" test is more interesting than a multiple choice test. The questions have the following pattern: I show you several artifacts which are related by the theory of object-oriented design and programming. Because of the dependencies between the artifacts, some of the information is redundant and can be recovered from the context by applying the objectives covered in the course. The information which you should discover is marked UNKNOWNx. If an unknown is not uniquely determined, mark the answer with *CHOICE*. An unknown may be anything, e.g., a number, an identifier, a character, two identifiers with a blank between them, a string etc. If an unknown is the empty string, give NOTHING as answer, e.g., UNKNOWN = NOTHING. Example: 5 + UNKNOWN1 = 8 UNKNOWN1 = 3 --------------- UNKNOWN2 * UNKNOWN3 = 20 UNKNOWN2 = 4 *CHOICE* UNKNOWN3 = 5 *CHOICE* At the beginning of a question we give the number of points per unknown. All the questions use the following class dictionary, called ES: EquationSystem = List(Equation). Equation = Variable "=" Exp "." . Exp : FunctionCall | Variable | Number. FunctionCall = "*call*" Function CommaList(Exp) . Variable = DemIdent. Function = DemIdent. Number = DemNumber. List(S) ~ {S}. CommaList(S) ~ "(" S {"," S} ")". 1 EquationSystem = List(Equation). 2 Equation = 3 Variable "=" 4 Exp "." . 5 Exp : 6 FunctionCall | 7 Variable | 8 Number. 9 FunctionCall = "*call*" Function 10 CommaList(Exp) . 11 Variable = DemIdent. 12 Function = DemIdent. 13 Number = DemNumber. 14 List(S) ~ {S}. 15 CommaList(S) ~ "(" S {"," S} ")". CommaList :15 10 Equation :2 1 EquationSystem :1 Exp :5 4 10 Function :12 9 FunctionCall :9 6 List :14 1 Number :13 8 Variable :11 3 7 QUESTION 1: ================================================== 45 UNKNOWNs, 2 points each: 90 points All traversal and transportation graphs are with respect to ES. Consider the following propagation directive: *from* EquationSystem *through* -> * , var , * *to* Variable Find the UNKNOWNs in the propagation graph: UNKNOWN1 = UNKNOWN2 . Equation = < UNKNOWN3 > UNKNOWN4 . UNKNOWN5 = . UNKNOWN6 ~ { UNKNOWN7 } . Consider the following propagation directive: *from* EquationSystem *bypassing* -> Equation , var , Variable *to* Variable Find the UNKNOWNs in the propagation graph: UNKNOWN8 = < UNKNOWN9 > UNKNOWN10 . UNKNOWN11 = < UNKNOWN12 > UNKNOWN13 . UNKNOWN14 : UNKNOWN15 | UNKNOWN16 *common* . UNKNOWN17 = < UNKNOWN18 > UNKNOWN19 . UNKNOWN20 = . UNKNOWN21 ~ { UNKNOWN22 } . UNKNOWN23 ~ UNKNOWN24 . Consider the following propagation directive (for traversal): *from* EquationSystem *through* -> Equation , var , Variable *to* Variable and the corresponding transportation directive: *from* EquationSystem *to* Variable Find the UNKNOWNs in the following transportation graph: UNKNOWN25 = < UNKNOWN26 > UNKNOWN27 . Equation = < UNKNOWN28> UNKNOWN29 . UNKNOWN30 = UNKNOWN31 . UNKNOWN32 ~ { UNKNOWN33 } . Consider the following propagation directive (for traversal): *from* EquationSystem *bypassing* -> Equation , var , Variable *to* Variable and the corresponding transportation directive: *from* Equation *to* Variable Find the UNKNOWNs in the following transportation graph: UNKNOWN34 = < UNKNOWN35 > UNKNOWN36 . UNKNOWN37 : UNKNOWN38 | UNKNOWN39 *common* . UNKNOWN40 = < UNKNOWN41 > UNKNOWN42 . UNKNOWN43 = . UNKNOWN44 ~ UNKNOWN45 . QUESTION 2: ========================================================= 40 UNKNOWNs, 2 points each: 80 points The class dictionary is ES. Consider the propagation pattern: *operation* void f(ostream& strm) *traverse* *from* EquationSystem *through* -> *,var,* *to* Variable *carry* *in* EquationSystem* c *along* *from* EquationSystem *to* Variable *at* EquationSystem c =(@ this @) *wrapper* Variable *prefix* (@ strm << this << "\t:" << this->get_variableName()->get_line_number() << "\t"; c->g(this,strm); strm << "\n";@) *operation* void g(Variable* v,ostream& strm) *traverse* *from* EquationSystem *bypassing* -> *,var,* *to* Variable *carry* *in* Equation* eq *along* *from* Equation *to* Variable *at* Equation eq = (@ this @) *wrapper* ~> Equation_List, Equation *prefix* (@ cout << "going through next equation " << each_Equation << endl; @) *wrapper* Variable *prefix* (@ cout << endl << this << " from " << eq << " compared with " << v << endl; if (this->g_equal(v)) { strm << "used on " << this->get_variableName()->get_line_number() << "\n"; } @) and the following input object: : EquationSystem ( < eqs > : Equation_List { : Equation ( < var > : Variable ( < variableName > : DemIdent "a" ) < exp > : Number ( < n > : DemNumber "1" ) ) , : Equation ( < var > : Variable ( < variableName > : DemIdent "b" ) < exp > : Number ( < n > : DemNumber "2" ) ) , : Equation ( < var > : Variable ( < variableName > : DemIdent "c" ) < exp > : FunctionCall ( < fn > : Function ( < functionName > : DemIdent "f" ) < args > : Exp_CommaList { : Variable ( < variableName > : DemIdent "a" ) , : FunctionCall ( < fn > : Function ( < functionName > : DemIdent "g" ) < args > : Exp_CommaList { : Variable ( < variableName > : DemIdent "b" ) } ) } ) ) , : Equation ( < var > : Variable ( < variableName > : DemIdent "d" ) < exp > : FunctionCall ( < fn > : Function ( < functionName > : DemIdent "h" ) < args > : Exp_CommaList { : Number ( < n > : DemNumber "1" ) , : Variable ( < variableName > : DemIdent "c" ) , : Number ( < n > : DemNumber "6" ) } ) ) } ) Find the UNKNOWNs in the following sentence and trace: The object in sentence form: a = UNKNOWN1. b = UNKNOWN2. c = *call* UNKNOWN3 (UNKNOWN4,*call* g(UNKNOWN5)). UNKNOWN6 = *call* UNKNOWN7(UNKNOWN8, UNKNOWN9, UNKNOWN10). >> void EquationSystem::f(ostream& strm) >> void UNKNOWN11::f(ostream& strm,EquationSystem* c) >> void UNKNOWN12::f(ostream& strm,EquationSystem* c) >> void UNKNOWN13::f(ostream& strm,EquationSystem* c) a :2 >> void EquationSystem::g(Variable* v,ostream& strm) >> void Equation_List::g(Variable* v,ostream& strm) going through next equation a = UNKNOWN14 . >> void UNKNOWN15::g(Variable* v,ostream& strm) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) << void UNKNOWN16::g(Variable* v,ostream& strm) going through next equation b = UNKNOWN17 . >> void UNKNOWN18::g(Variable* v,ostream& strm) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) << void UNKNOWN19::g(Variable* v,ostream& strm) going through next equation UNKNOWN20 >> void Equation::g(Variable* v,ostream& strm) >> void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) >> void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) >> void Variable::g(Variable* v,ostream& strm,Equation* eq) a from UNKNOWN21 compared with a used on 4 << void UNKNOWN22::g(Variable* v,ostream& strm,Equation* eq) >> void UNKNOWN23::g(Variable* v,ostream& strm,Equation* eq) >> void UNKNOWN24::g(Variable* v,ostream& strm,Equation* eq) >> void UNKNOWN25::g(Variable* v,ostream& strm,Equation* eq) b from UNKNOWN26 compared with a << void UNKNOWN27::g(Variable* v,ostream& strm,Equation* eq) << void UNKNOWN28::g(Variable* v,ostream& strm,Equation* eq) << void UNKNOWN29::g(Variable* v,ostream& strm,Equation* eq) << void UNKNOWN30::g(Variable* v,ostream& strm,Equation* eq) << void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) << void Equation::g(Variable* v,ostream& strm) going through next equation UNKNOWN31 >> void Equation::g(Variable* v,ostream& strm) >> void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) >> void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) >> void Variable::g(Variable* v,ostream& strm,Equation* eq) c from UNKNOWN32 compared with UNKNOWN33 << void Variable::g(Variable* v,ostream& strm,Equation* eq) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) << void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) << void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) << void Equation::g(Variable* v,ostream& strm) << void Equation_List::g(Variable* v,ostream& strm) << void EquationSystem::g(Variable* v,ostream& strm) << void Variable::f(ostream& strm,EquationSystem* c) << void Equation::f(ostream& strm,EquationSystem* c) >> void Equation::f(ostream& strm,EquationSystem* c) >> void Variable::f(ostream& strm,EquationSystem* c) b :3 >> void EquationSystem::g(Variable* v,ostream& strm) >> void Equation_List::g(Variable* v,ostream& strm) going through next equation a = UNKNOWN34 . >> void Equation::g(Variable* v,ostream& strm) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) << void Equation::g(Variable* v,ostream& strm) going through next equation b = UNKNOWN35 . >> void Equation::g(Variable* v,ostream& strm) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) << void Equation::g(Variable* v,ostream& strm) going through next equation UNKNOWN36 >> void Equation::g(Variable* v,ostream& strm) >> void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) >> void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) >> void Variable::g(Variable* v,ostream& strm,Equation* eq) a from UNKNOWN37 compared with b << void Variable::g(Variable* v,ostream& strm,Equation* eq) >> void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) >> void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) >> void Variable::g(Variable* v,ostream& strm,Equation* eq) b from UNKNOWN38 compared with b used on 4 << void Variable::g(Variable* v,ostream& strm,Equation* eq) << void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) << void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) << void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) << void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) << void Equation::g(Variable* v,ostream& strm) going through next equation UNKNOWN39 >> void Equation::g(Variable* v,ostream& strm) >> void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) >> void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) >> void Variable::g(Variable* v,ostream& strm,Equation* eq) c from UNKNOWN40 compared with b << void Variable::g(Variable* v,ostream& strm,Equation* eq) >> void Number::g(Variable* v,ostream& strm,Equation* eq) << void Number::g(Variable* v,ostream& strm,Equation* eq) << void Exp_CommaList::g(Variable* v,ostream& strm,Equation* eq) << void FunctionCall::g(Variable* v,ostream& strm,Equation* eq) << void Equation::g(Variable* v,ostream& strm) << void Equation_List::g(Variable* v,ostream& strm) << void EquationSystem::g(Variable* v,ostream& strm) << void Variable::f(ostream& strm,EquationSystem* c) << void Equation::f(ostream& strm,EquationSystem* c) >> void Equation::f(ostream& strm,EquationSystem* c) >> void Variable::f(ostream& strm,EquationSystem* c) c :4 >> void EquationSystem::g(Variable* v,ostream& strm) >> void Equation_List::g(Variable* v,ostream& strm) rest deleted QUESTION 3: =================================================== 62 UNKNOWNs, 1 point each: 62 points Given the following sentence A = 1. B = 2. C = 3. Z = *call* f(A, *call* g(B), *call* h(*call* i(C))). find the UNKNOWNs in the following object: : UNKNOWN1 ( < eqs > : UNKNOWN2 { : Equation ( < var > : UNKNOWN3 ( < variableName > : DemIdent "UNKNOWN4" ) < exp > : Number ( < n > : DemNumber "UNKNOWN5" ) ) , : UNKNOWN6 ( < UNKNOWN7 > : UNKNOWN8 ( < UNKNOWN9 > : UNKNOWN10 "UNKNOWN11" ) < UNKNOWN12 > : UNKNOWN13 ( < UNKNOWN14 > : UNKNOWN15 "UNKNOWN16" ) ) , : Equation ( < var > : Variable ( < variableName > : DemIdent "C" ) < exp > : Number ( < n > : DemNumber "3" ) ) , : UNKNOWN17 ( < UNKNOWN18 > : UNKNOWN19 ( < UNKNOWN20 > : UNKNOWN21 "UNKNOWN22" ) < UNKNOWN23 > : UNKNOWN24 ( < UNKNOWN25 > : UNKNOWN26 ( < UNKNOWN27 > : DemIdent "UNKNOWN28" ) < UNKNOWN29 > : UNKNOWN30 { : UNKNOWN31 ( < variableName > : DemIdent "A" ) , : UNKNOWN32 ( < fn > : UNKNOWN33 ( < UNKNOWN34 > : UNKNOWN35 "UNKNOWN36" ) < UNKNOWN37 > : UNKNOWN38 { : UNKNOWN39 ( < UNKNOWN40 > : UNKNOWN41 "UNKNOWN42" ) } ) , : UNKNOWN43 ( < UNKNOWN44 > : UNKNOWN45 ( < UNKNOWN46 > : UNKNOWN47 "UNKNOWN48" ) < UNKNOWN49 > : UNKNOWN50 { : UNKNOWN51 ( < UNKNOWN52 > : UNKNOWN53 ( < UNKNOWN54 > : UNKNOWN55 "UNKNOWN56" ) < UNKNOWN57 > : UNKNOWN58 { : UNKNOWN59 ( < UNKNOWN60 > : UNKNOWN61 "UNKNOWN62" ) } ) } ) } ) ) } ) QUESTION 4: ======================================================= 24 UNKNOWNs, 2 points each: 48 points Consider the following propagation patterns *operation* void f(ostream& strm) *traverse* *from* EquationSystem *through* -> *,var,* *to* Variable *carry* *in* EquationSystem* c *along* *from* EquationSystem *to* Variable *at* EquationSystem c =(@ this @) *wrapper* Variable *prefix* (@ strm << this << "\t:" << this->get_variableName()->get_line_number() << "\t"; c->g(this,strm); strm << "\n";@) *operation* void g(Variable* v,ostream& strm) *traverse* *from* EquationSystem *bypassing* -> *,var,* *to* Variable *carry* *in* Equation* eq *along* *from* Equation *to* Variable *at* Equation eq = (@ this @) *wrapper* ~> Equation_List, Equation *prefix* (@ cout << "going through next equation " << each_Equation << endl; @) *wrapper* Variable *prefix* (@ cout << endl << this << " from " << eq << " compared with " << v << endl; if (this->g_equal(v)) { strm << "used on " << this->get_variableName()->get_line_number() << "\n"; } @) Find the UNKNOWNs in the following C++ program: void EquationSystem::f( ostream& strm ) { // variables for carrying in and out EquationSystem* c ; // assignments for carrying in c = UNKNOWN1 ; // outgoing calls eqs ->f( UNKNOWN2 , UNKNOWN3 ); } void Equation::f( ostream& strm, EquationSystem* c ) { // outgoing calls var ->f( UNKNOWN4 , UNKNOWN5 ); } void Variable::f( ostream& strm, EquationSystem* c ) { // prefix blocks strm << this << "\t:" << this->get_variableName()->get_line_number() << "\t"; c->g(this,strm); strm << "\n"; } void Equation_List::f( ostream& strm, EquationSystem* c ) { // outgoing calls Equation_list_iterator next_Equation(*this); Equation* each_Equation; UNKNOWN6 ( UNKNOWN7 = UNKNOWN8() ) { UNKNOWN9->f( strm , c ); } } void EquationSystem::g( Variable* v,ostream& strm ) { // outgoing calls eqs ->g( v , strm ); } void Equation::g( Variable* v,ostream& strm ) { // variables for carrying in and out UNKNOWN10 // assignments for carrying in UNKNOWN11 // outgoing calls exp ->g( UNKNOWN12 , UNKNOWN13 , UNKNOWN14 ); } void Exp::g( Variable* v,ostream& strm, Equation* eq ) { } void Number::g( Variable* v,ostream& strm, Equation* eq ) { UNKNOWN15 } void FunctionCall::g( Variable* v,ostream& strm, Equation* eq ) { // outgoing calls args ->g( v , strm , eq ); } void Variable::g( Variable* v,ostream& strm, Equation* eq ) { cout << endl << this << " from " << eq << " UNKNOWN16 with " << v << endl; if (this->g_equal(v)) { strm << "used on " << this->UNKNOWN17()->get_line_number() << "\n"; } } void Equation_List::g( Variable* v,ostream& strm ) { // outgoing calls Equation_list_iterator next_Equation(*this); Equation* each_Equation; UNKNOWN18 ( UNKNOWN19 = UNKNOWN20() ) { cout << "UNKNOWN21" << each_Equation << endl; each_Equation->g( v , strm ); } } void Exp_CommaList::g( Variable* v,ostream& strm, Equation* eq ) { // outgoing calls Exp_list_iterator next_Exp(*this); Exp* each_Exp; UNKNOWN22 ( UNKNOWN23 = UNKNOWN24() ) { each_Exp->g( v , strm , eq ); } } HAPPY HOLIDAYS !!!