Question 1: =========== /proj/adaptive/lieber/regression-test/f-exercise-v Remark: At = Bt Ct. is an abbreviation for At = Bt Ct. Consider the following class dictionary: ------------------------------------------------------------- Class Dictionary ------------------------------------------------------------- 1 Example = B1. 2 A1 : B1 | B2 *common* [A2] "endA1". 3 A2 : B3 | B4 *common* [A3] "endA2". 4 A3 : B5 | B6. 5 B1 = "b1" ["down" C1] ["b2" B2]. 6 B2 : C1 *common* [B3] "endB2". 7 B3 = "b3" ["down" C2] ["b4" B4]. 8 B4 : C2 *common* [B5] "endB4". 9 B5 = "b5" ["down" C3] ["b6" B6]. 10 B6 : C3. 11 C1 = "c1". 12 C2 = "c2". 13 C3 = "c3". ------------------------------------------------------------- Alphabetically Sorted Cross Reference List ------------------------------------------------------------- A1 :2 A2 :3 2 A3 :4 3 B1 :5 1 2 B2 :6 2 5 B3 :7 3 6 B4 :8 3 7 B5 :9 4 8 B6 :10 4 9 C1 :11 5 6 C2 :12 7 8 C3 :13 9 10 Example :1 =================================================== Find the unknowns in the following propagation directives and propagation graphs: Propagation directive: *traverse* *from* Example *bypassing* -> B3,*,*, -> *,a3,*, -> *,*,C3 *to* C3 Equivalent propagation directive, expanded for class dictionary: *from* Example *bypassing* -> B3 , c2 , C2 , -> B3 , b4 , B4 , -> A2 , a3 , A3 , -> B5 , c3 , C3 *to* C3 Propagation graph for traversal: *source* { Example } Example = < b1 > B1 (*inherits* ) . A1 : *common* [ < a2 > A2 ] (*inherits* ) . A2 : B4 *common* (*inherits* ) . B1 = [ < c1 > C1 ] [ < b2 > B2 ] (*inherits* A1 ) . B2 : C1 *common* (*inherits* A1 ) . B4 : C2 *common* [ < b5 > B5 ] (*inherits* ) . B5 = [ < b6 > B6 ] (*inherits* ) . B6 : C3 *common* (*inherits* ) . C1 = (*inherits* B2 ) . C2 = (*inherits* B4 ) . C3 = (*inherits* ) . // There are 13 classes in total // There are 11 classes in the propagation schema // There are 2 classes not in the propagation graph // They are A3 B3 =========================================================== Propagation directive: *traverse* *from* Example *bypassing* -> A1,*,*, -> A2,*,*, -> *,*,C1, -> *,*,C2, -> *,*,C3 *to* C3 Equivalent, expanded propagation directive *from* Example *bypassing* -> A1 , a2 , A2 , -> A2 , a3 , A3 , -> B1 , c1 , C1 , -> B3 , c2 , C2 , -> B5 , c3 , C3 *to* C3 Propagation graph for traversal: *source* Example *target* C3 *paths* Example = < b1 > B1 (*inherits* ) . B1 = [ < b2 > B2 ] (*inherits* ) . B2 : C1 *common* [ < b3 > B3 ] (*inherits* ) . B3 = [ < b4 > B4 ] (*inherits* ) . B4 : C2 *common* [ < b5 > B5 ] (*inherits* ) . B5 = [ < b6 > B6 ] (*inherits* ) . B6 : C3 *common* (*inherits* ) . C1 = (*inherits* B2 ) . C2 = (*inherits* B4 ) . C3 = (*inherits* ) . // There are 13 classes in total // There are 10 classes in the propagation schema // There are 3 classes not in the propagation graph // They are A1 A2 A3 ======================================== Find the unknowns in the following propagation pattern and corresponding C++ program. *operation* void f6() *traverse* *from* Example *bypassing* -> A1,*,*, -> A2,*,*, -> *,*,C1, -> *,*,C2, -> *,*,C3 *to* C3 *wrapper* C3 *prefix* (@ cout << endl << "done" << endl; @) C++ program: void Example::f6( ) { this->get_b1()->f6( ); } void B1::f6( ) { if ( this->get_b2() != NULL ) { this->get_b2()->f6( ); } } void B2::f6( ) { if ( this->get_b3() != NULL ) { this->get_b3()->f6( ); } } void B3::f6( ) { if ( this->get_b4() != NULL ) { this->get_b4()->f6( ); } } void B4::f6( ) { if ( this->get_b5() != NULL ) { this->get_b5()->f6( ); } } void B5::f6( ) { if ( this->get_b6() != NULL ) { this->get_b6()->f6( ); } } void B6::f6( ) { } void C1::f6( ) { this->B2::f6( ); } void C2::f6( ) { this->B4::f6( ); } void C3::f6( ) { cout << endl << "done" << endl; } ======================================== Consider the flattened form of the above class dictionary. Example = B1 . A1 : B1 | B2 *common* . A2 : B3 | B4 *common* . A3 : B5 | B6 *common* . B1 = "b1" [ "down" C1 ] [ "b2" B2 ] [ A2 ] "endA1" . B2 : C1 *common* . B3 = "b3" [ "down" C2 ] [ "b4" B4 ] [ A3 ] "endA2" . B4 : C2 *common* . B5 = "b5" [ "down" C3 ] [ "b6" B6 ] . B6 : C3 *common* . C1 = "c1" [ B3 ] "endB2" [ A2 ] "endA1" . C2 = "c2" [ B5 ] "endB4" [ A3 ] "endA2" . C3 = "c3" . Find the unknowns in the following object and corresponding sentence: Object: : Example ( < b1 > : B1 ( < c1 > : C1 ( < b3 > : B3 ( < c2 > : C2 ( < b5 > : B5 ( < c3 > : C3 ( ) < b6 > : C3 ( ) ) ) ) ) ) ) Sentence: b1 down c1 b3 down c2 b5 down c3 b6 c3 endB4 // for C2 endA2 // for C2 endA2 // for B3 endB2 // for C1 endA1 // for C1 endA1 // for B1 Question 3: f-meal-t Consider the following ------------------------------------------------------------- Class Dictionary ------------------------------------------------------------- 1 RestaurantOrder = OrderList. 2 OrderList ~ {Order}. 3 Order = "ORDER:" 4 [ "Appetizer:" Appetizer_List ] 5 "Entree:" Entree 6 "Salad" Salad 7 [ "Dessert" Dessert ] 8 "Bon" "Appetit!". 9 Appetizer_List ~ Appetizer { "and" Appetizer }. 10 Entree : Beef | Chicken | Vegetarian | Fish . 11 Dessert = "with" DemNumber "calories". 12 Appetizer : Soup| Nachos | 13 Potato_Skins | Stuffed_Mushrooms. 14 Soup = "Soup". 15 Nachos = "Nachos". 16 Potato_Skins = "Potato" "Skins". 17 Stuffed_Mushrooms = "Stuffed" "Mushrooms". 18 Salad = Lettuce "with" 19 Salad_Dressing "dressing" 20 "and" Vegetable. 21 Beef = "Beef". 22 Chicken = "Chicken". 23 Vegetarian = "Vegetarian Entree". 24 Lettuce = . 25 Salad_Dressing = DemString "(" 26 DemNumber "calories )". 27 Vegetable : Tomato| Carrot. 28 Tomato = "tomatoes". 29 Carrot = "carrots". 30 Fish : OceanFish | LakeFish 31 *common* "Fish -" DemString. 32 LakeFish = "Lake". 33 OceanFish = "Ocean". ------------------------------------------------------------- Alphabetically Sorted Cross Reference List ------------------------------------------------------------- Appetizer :12 9 9 Appetizer_List :9 4 Beef :21 10 Carrot :29 27 Chicken :22 10 Dessert :11 7 Entree :10 5 Fish :30 10 LakeFish :32 30 Lettuce :24 18 Nachos :15 12 OceanFish :33 30 Order :3 2 OrderList :2 1 Potato_Skins :16 13 RestaurantOrder :1 Salad :18 6 Salad_Dressing :25 19 Soup :14 12 Stuffed_Mushrooms :17 13 Tomato :28 27 Vegetable :27 20 Vegetarian :23 10 Find the unknowns in the following propagation pattern, object, corresponding sentence, trace (for the object) and C++ program. // // Print the salad dressing name and number of calories for the // people who ordered carrots on their salad. // *operation* void f() *traverse* *from* RestaurantOrder *to* Salad *wrapper* Salad *prefix* (@ this -> f(dressing); @) *operation* void f(Salad_Dressing* d) *traverse* *from* Salad *to* Carrot *wrapper* Carrot *prefix* (@ d->g_print(); cout << "\n"; @) : RestaurantOrder ( < orders > : OrderList { : Order ( < entree > : Beef ( ) < salad > : Salad ( < greens > : Lettuce ( ) < dressing > : Salad_Dressing ( < brandName > : DemString "Bleu Cheese" < calories > : DemNumber "1500" ) < garnish > : Carrot ( ) ) < dessert > : Dessert ( < calories > : DemNumber "1000" ) ) , : Order ( < appetizer > : Appetizer_List { : Nachos ( ) , : Potato_Skins ( ) , : Soup ( ) } < entree > : Chicken ( ) < salad > : Salad ( < greens > : Lettuce ( ) < dressing > : Salad_Dressing ( < brandName > : DemString "French" < calories > : DemNumber "550" ) < garnish > : Tomato ( ) ) ) , : Order ( < appetizer > : Appetizer_List { : Stuffed_Mushrooms ( ) } < entree > : OceanFish ( < name > : DemString "Native Swordfish" ) < salad > : Salad ( < greens > : Lettuce ( ) < dressing > : Salad_Dressing ( < brandName > : DemString "Italian" < calories > : DemNumber "250" ) < garnish > : Carrot ( ) ) < dessert > : Dessert ( < calories > : DemNumber "5700" ) ) } ) ORDER: Entree: Beef Salad with "Bleu Cheese" (1500 calories ) dressing and carrots Dessert with 1000 calories Bon Appetit! ORDER: Appetizer: Nachos and Potato Skins and Soup Entree: Chicken Salad with "French" (550 calories ) dressing and tomatoes Bon Appetit! ORDER: Appetizer: Stuffed Mushrooms Entree: Ocean Fish - "Native Swordfish" Salad with "Italian" (250 calories ) dressing and carrots Dessert with 5700 calories Bon Appetit! Salad dressings for people who ordered carrots on their salad: >> void RestaurantOrder::f(), "part1-DEM.C", line 6 >> void OrderList::f(), "part1-DEM.C", line 23 >> void Order::f(), "part1-DEM.C", line 46 >> void Salad::f(), "part1-DEM.C", line 63 >> void Salad::f(Salad_Dressing* d), "part1-DEM.C", line 80 >> void Carrot::f(Salad_Dressing* d), "part1-DEM.C", line 118 "Bleu Cheese" ( 1500 calories ) << void Carrot::f(Salad_Dressing* d), "part1-DEM.C", line 118 << void Salad::f(Salad_Dressing* d), "part1-DEM.C", line 80 << void Salad::f(), "part1-DEM.C", line 63 << void Order::f(), "part1-DEM.C", line 46 >> void Order::f(), "part1-DEM.C", line 46 >> void Salad::f(), "part1-DEM.C", line 63 >> void Salad::f(Salad_Dressing* d), "part1-DEM.C", line 80 >> void Tomato::f(Salad_Dressing* d), "part1-DEM.C", line 113 << void Tomato::f(Salad_Dressing* d), "part1-DEM.C", line 113 << void Salad::f(Salad_Dressing* d), "part1-DEM.C", line 80 << void Salad::f(), "part1-DEM.C", line 63 << void Order::f(), "part1-DEM.C", line 46 >> void Order::f(), "part1-DEM.C", line 46 >> void Salad::f(), "part1-DEM.C", line 63 >> void Salad::f(Salad_Dressing* d), "part1-DEM.C", line 80 >> void Carrot::f(Salad_Dressing* d), "part1-DEM.C", line 118 "Italian" ( 250 calories ) << void Carrot::f(Salad_Dressing* d), "part1-DEM.C", line 118 << void Salad::f(Salad_Dressing* d), "part1-DEM.C", line 80 << void Salad::f(), "part1-DEM.C", line 63 << void Order::f(), "part1-DEM.C", line 46 << void OrderList::f(), "part1-DEM.C", line 23 << void RestaurantOrder::f(), "part1-DEM.C", line 6 void RestaurantOrder::f( ) { this->get_orders()->f( ); } void OrderList::f( ) { Order_list_iterator next_Order(*this); Order* each_Order; while ( each_Order = next_Order() ) { each_Order->f( ); } } void Order::f( ) { this->get_salad()->f( ); } void Salad::f( ) { // prefix blocks this -> f(dressing); } void Salad::f( Salad_Dressing* d ) { this->get_garnish()->f( d ); } void Vegetable::f( Salad_Dressing* d ) { } void Tomato::f( Salad_Dressing* d ) { } void Carrot::f( Salad_Dressing* d ) { // prefix blocks d->g_print(); cout << "\n"; } Question 2: Consider the following ------------------------------------------------------------- Class Dictionary ------------------------------------------------------------- 1 Example = A1. 2 A1 : B. 3 B = C H. 4 D1 : C *common* E. 5 C = . 6 E = F H. 7 G1 : F *common* G. 8 F = . 9 G = H. 10 H = . ------------------------------------------------------------- Alphabetically Sorted Cross Reference List ------------------------------------------------------------- A1 :2 1 B :3 2 C :5 3 4 D1 :4 E :6 4 Example :1 F :8 6 7 G :9 7 G1 :7 H :10 3 6 9 Find the unknowns in the following object. It corresponds to the empty sentence. : Example ( < a1 > : B ( < c > : C ( < e > : E ( < f > : F ( < g > : G ( < h > : H ( ) ) ) < h > : H ( ) ) ) < h > : H ( ) ) ) ======================================== Find the unknowns in the following propagation pattern and corresponding C++ program: Propagation pattern: *operation* void fun() *traverse* *from* Example *via* E *to* H *wrapper* H *prefix* (@ cout << endl << "done" << endl; @) C++ program: void Example::fun( ) { this->get_a1()->fun( ); } void A1::fun( ) { } void B::fun( ) { this->get_c()->fun( ); } void D1::fun( ) { this->get_e()->fun( ); } void C::fun( ) { this->D1::fun( ); } void E::fun( ) { this->get_f()->fun( ); this->get_h()->fun( ); } void G1::fun( ) { this->get_g()->fun( ); } void F::fun( ) { this->G1::fun( ); } void G::fun( ) { this->get_h()->fun( ); } void H::fun( ) { // prefix blocks cout << endl << "done" << endl; }