See $R/f-travel Question 1: ? UNKNOWNS, 4 points per unknown Consider the following class dictionary: SmallTravelSystem = "small travel system" "passengers" List(Passenger) "taxiCompanies" List(TaxiCompany) "airlines" List(Airline). Passenger = "passenger" "events" List(Event). List(S) ~ "(" {S} ")". TaxiCompany = "taxi company" TaxiCompanyName Dispatcher List(Taxi). Taxi = "taxi" DemString. Airline = "airline" AirlineName TicketAgent List(Airplane). Airplane = "airplane" DemString [ AirlineName]. TicketAgent = . Dispatcher = . TaxiCompanyName = DemString. AirlineName = DemString. Event: Depart | OrderTaxi | OrderPlaneTicket | UseTaxi | UseAirplane | Arrive. Depart = "depart". Arrive = "arrive". OrderTaxi = "order taxi" TaxiCompanyName. OrderPlaneTicket = "order plane ticket" AirlineName. UseTaxi = Taxi. UseAirplane = Airplane. Find the unknowns in the following propagation patterns and propagation graphs: // print for a passenger the ids of the airplanes used. // The event history says with which planes the passenger has flown. *operation* void airplanes_used() *traverse* *from* Passenger *through* -> *,eventHistory,* *to* Airplane *wrapper* Airplane *prefix* (@ cout << "**********airplane id =" << this -> get_id() << endl; @) // print for a given passenger object // the names of the airlines s/he uses and the total number // of planes owned by the airline. // An airline may sell tickets of other airlines, // so the search has to be done through the UseAirplane class. *operation* void number_of_planes_of_passengers_airlines(SmallTravelSystem* s) *traverse* *from* Passenger *through* -> *,eventHistory,* *via* UseAirplane *to* AirlineName You are right: *from* Passenger *through* ->*,airplane,* *to* AirlineName is also correct. *wrapper* AirlineName *prefix* (@ cout << "**************airline" << this << endl ; s->number_of_planes_of_airline(this); @) *operation* void number_of_planes_of_airline(AirlineName* an) *traverse* *from* SmallTravelSystem *through* -> *,airlines,* *to* Airline *wrapper* Airline *prefix* (@ if (this->get_name()->g_equal(an)) cout << "********** number of air planes =" << this -> get_airplanes() -> list_length() << endl; @) ========================================= ========================================= Propagation graphs for each of the propagation patterns *operation* void airplanes_used() Propagation graph for traversal: *source* { Passenger } *target* { Airplane } *paths* Passenger = < eventHistory > Event_List . Event_List ~ { Event } . Event : UseAirplane *common* . UseAirplane = < airplane > Airplane . Airplane = . *operation* void number_of_planes_of_passengers_airlines(SmallTravelSystem* s) Propagation graph for traversal: *source* { Passenger } *target* { AirlineName } *paths* Passenger = < eventHistory > Event_List . Event_List ~ { Event } . Event : UseAirplane *common* . UseAirplane = < airplane > Airplane . Airplane = [ < belongs_to > AirlineName ] . AirlineName = . *operation* void number_of_planes_of_airline(AirlineName* an) Propagation graph for traversal: *source* { SmallTravelSystem } *target* { Airline } *paths* SmallTravelSystem = < airlines > Airline_List . Airline_List ~ { Airline } . Airline = . Question 2: =========== 2 UNKNOWN, 30 points Consider the following propagation pattern: *operation* void f() *traverse* *join* (*from* A *to* B, *from* B *to* C) // The same as: *from* A *via* B *to* C *wrapper* C *prefix* (@ cout << this << endl; @) When we customize a join propagation directive, such as the one above, we have to watch out for short cuts. For the directive *join*(D1,D2) and a customizer G the short-cut property holds if in G there is a path from the source of D1 to the target of D2 not going through the target of D1. Such a path is a short-cut path. Consider the customizers below and answer the following question: Does the short-cut property hold for all customizers with the propagation directive in the above propagation pattern? UNKNOWN1 YES. Give a brief explanation: UNKNOWN2 In all three customizers there is a short-cut path from A to C. Case 1: A = B C. B = [A] C. C = . Case 2: A = B C. B = C. C = [A]. Case 3: A = B C. B = [A]. C = . Question 3: =========== Find the unknowns in class dictionary cd-print below so that the object below : SmallTravelSystem ( < passengers > : Passenger_List { : Passenger ( < eventHistory > : Event_List { : OrderTaxi ( < taxicompanyname > : TaxiCompanyName ( < name > : DemString "TownTaxi" ) ) , : OrderPlaneTicket ( < airlinename > : AirlineName ( < name > : DemString "Delta" ) ) , : Depart ( ) , : UseTaxi ( < taxi > : Taxi ( < id > : DemString "taxi1" ) ) , : UseAirplane ( < airplane > : Airplane ( < id > : DemString "air1" < belongs_to > : AirlineName ( < name > : DemString "Delta" ) ) ) } ) } < taxiCompanies > : TaxiCompany_List { : TaxiCompany ( < name > : TaxiCompanyName ( < name > : DemString "TownTaxi" ) < dispatcher > : Dispatcher ( ) < taxis > : Taxi_List { : Taxi ( < id > : DemString "taxi1" ) } ) } < airlines > : Airline_List { : Airline ( < name > : AirlineName ( < name > : DemString "Delta" ) < ticketagent > : TicketAgent ( ) < airplanes > : Airplane_List { : Airplane ( < id > : DemString "air1" < belongs_to > : AirlineName ( < name > : DemString "Delta" ) ) } ) } ) gets printed as kleines Reisesystem Passagiere ( Passagier Ereignisse ( bestelle Taxi "TownTaxi" bestelle Flugschein "Delta" Abfahrt Taxi "taxi1" Flugzeug "air1" "Delta" ) ende ) Taxifirmen ( Taxifirma "TownTaxi" ( Taxi "taxi1" ) ) Fluggesellschaften ( Fluggesellschaft "Delta" ( Flugzeug "air1" "Delta" ) ) ende // Class dictionary (cd-print) for printing SmallTravelSystem = "kleines Reisesystem" "Passagiere" Passenger_List "Taxifirmen" TaxiCompany_List "Fluggesellschaften" Airline_List "ende". Passenger = "Passagier" "Ereignisse" Event_List "ende". TaxiCompany = "Taxifirma" TaxiCompanyName Dispatcher Taxi_List . Taxi = "Taxi" DemString . Airline = "Fluggesellschaft" AirlineName TicketAgent Airplane_List . Airplane = "Flugzeug" DemString [ AirlineName ] . TicketAgent = . Dispatcher = . TaxiCompanyName = DemString . AirlineName = DemString . Event : Depart | OrderTaxi | OrderPlaneTicket | UseTaxi | UseAirplane | Arrive *common* . Depart = "Abfahrt" . Arrive = "Ankunft" . OrderTaxi = "bestelle Taxi" TaxiCompanyName . OrderPlaneTicket = "bestelle Flugschein" AirlineName . UseTaxi = Taxi . UseAirplane = Airplane . Passenger_List ~ "(" { Passenger } ")" . TaxiCompany_List ~ "(" { TaxiCompany } ")" . Airline_List ~ "(" { Airline } ")" . Event_List ~ "(" { Event } ")" . Taxi_List ~ "(" { Taxi } ")" . Airplane_List ~ "(" { Airplane } ")" . Question 4: =========== Consider the class dictionary from question 1. Consider the following transportation customizer restrictions discussed in class and in the book. I use here better names as follows: -------------------------- Getting-in Restriction: "can get in only through a transportation source" If a vertex v in the transportation graph has an incoming non-transportation edge, then v must be a source vertex of the transportation directive. -------------------------- -------------------------- No-return Restriction: "can not return to source" A source vertex of a transportation (or traversal) directive cannot have incoming edges in the transportation graph. -------------------------- Find the UNKNOWNS below: //*operation* void transp2() // *traverse* // *from* SmallTravelSystem // *carry* *in* int i // *along* // *from* Passenger // *to* Airplane // // *operation* void transp2 ( ) // propagate: error: // the Getting-in Restriction is violated. // The repetition edge '~> Airplane_List,Airplane' // which is in the traversal graph but not in the // transportation graph is not allowed, // since 'Airplane' is in the transporation graph // but not a transportation source. *operation* void transp1() *traverse* *from* SmallTravelSystem *carry* *in* int i *along* *from* Passenger *to* Taxi // *operation* void transp1 ( ) // propagate: error: // the Getting-in Restriction is violated. // The repetition edge '~> Taxi_List,Taxi' // which is in the traversal graph but not in the // transportation graph is not allowed, // since 'Taxi' is in the transporation graph // but not a transportation source. Question 5 ========== The class dictionary from question 1 is used. Consider the propagation patterns, sentence and output trace below. Find the UNKNOWNs. // For a SmallTravelSystem-object // print the event history of all passengers who are taxi users *operation* void query1() *traverse* *from* SmallTravelSystem *via* Passenger *to* Taxi // transportation pattern *carry* *in* Event_List* etl= (@ eventHistory @) *along* *from* Passenger *to* Taxi *wrapper* Taxi *prefix* (@ cout << "passenger event history " << etl << this << endl; @) // end transportation pattern // For a SmallTravelSystem-object // print for each taxi used by a passenger the taxi company name of the // company controlling the taxis. *operation* void query2() *traverse* *from* SmallTravelSystem *via* Passenger *to* Taxi // transportation pattern *carry* *out* DemString* taxi_id *along* *from* SmallTravelSystem *via* Passenger *to* Taxi *at* Taxi taxi_id = (@ id @) *wrapper* SmallTravelSystem *suffix* (@ this -> find(taxi_id); @) // end transportation pattern *operation* void find(DemString* taxi_id) *traverse* *from* SmallTravelSystem *through* -> *, taxiCompanies, * *to* Taxi // transportation pattern *carry* *in* TaxiCompanyName* tcn = (@ name @) *along* *from* TaxiCompany *to* Taxi *wrapper* Taxi *prefix* (@ if (id -> g_equal(taxi_id)) cout << "taxi company name " << tcn << endl; @) // end transportation pattern small travel system passengers ( passenger events ( order taxi "TownTaxi" order plane ticket "Delta" depart taxi "taxi1" airplane "air1" "Delta")) taxiCompanies ( taxi company "TownTaxi" (taxi "taxi1")) airlines ( airline "Delta" (airplane "air1" "Delta")) >> void SmallTravelSystem::query1() >> void Passenger_List::query1() >> void Passenger::query1() >> void Event_List::query1(Event_List* etl) >> void Event::query1(Event_List* etl) >> at OrderTaxi , *** PREMATURELY TERMINATED *** << at OrderTaxi , *** PREMATURELY TERMINATED *** << void Event::query1(Event_List* etl) >> void Event::query1(Event_List* etl) >> at OrderPlaneTicket , *** PREMATURELY TERMINATED *** << at OrderPlaneTicket , *** PREMATURELY TERMINATED *** << void Event::query1(Event_List* etl) >> void Event::query1(Event_List* etl) >> at Depart , *** PREMATURELY TERMINATED *** << at Depart , *** PREMATURELY TERMINATED *** << void Event::query1(Event_List* etl) >> void UseTaxi::query1(Event_List* etl) >> void Taxi::query1(Event_List* etl) passenger event history events ( order taxi "TownTaxi" order plane ticket "Delta" depart taxi "taxi1" airplane "air1" "Delta") taxi "taxi1" << void Taxi::query1(Event_List* etl) << void UseTaxi::query1(Event_List* etl) >> void Event::query1(Event_List* etl) >> at UseAirplane , *** PREMATURELY TERMINATED *** << at UseAirplane , *** PREMATURELY TERMINATED *** << void Event::query1(Event_List* etl) << void Event_List::query1(Event_List* etl) << void Passenger::query1() << void Passenger_List::query1() << void SmallTravelSystem::query1() >> void SmallTravelSystem::query2() >> void Passenger_List::query2(DemString* & taxi_id) >> void Passenger::query2(DemString* & taxi_id) >> void Event_List::query2(DemString* & taxi_id) >> void Event::query2(DemString* & taxi_id) >> at OrderTaxi , *** PREMATURELY TERMINATED *** << at OrderTaxi , *** PREMATURELY TERMINATED *** << void Event::query2(DemString* & taxi_id) >> void Event::query2(DemString* & taxi_id) >> at OrderPlaneTicket , *** PREMATURELY TERMINATED *** << at OrderPlaneTicket , *** PREMATURELY TERMINATED *** << void Event::query2(DemString* & taxi_id) >> void Event::query2(DemString* & taxi_id) >> at Depart , *** PREMATURELY TERMINATED *** << at Depart , *** PREMATURELY TERMINATED *** << void Event::query2(DemString* & taxi_id) >> void UseTaxi::query2(DemString* & taxi_id) >> void Taxi::query2(DemString* & taxi_id) << void Taxi::query2(DemString* & taxi_id) << void UseTaxi::query2(DemString* & taxi_id) >> void Event::query2(DemString* & taxi_id) >> at UseAirplane , *** PREMATURELY TERMINATED *** << at UseAirplane , *** PREMATURELY TERMINATED *** << void Event::query2(DemString* & taxi_id) << void Event_List::query2(DemString* & taxi_id) << void Passenger::query2(DemString* & taxi_id) << void Passenger_List::query2(DemString* & taxi_id) >> void SmallTravelSystem::find(DemString* taxi_id) >> void Passenger_List::find(DemString* taxi_id) >> void Passenger::find(DemString* taxi_id) << void Passenger::find(DemString* taxi_id) << void Passenger_List::find(DemString* taxi_id) >> void TaxiCompany_List::find(DemString* taxi_id) >> void TaxiCompany::find(DemString* taxi_id) >> void Taxi_List::find(DemString* taxi_id,TaxiCompanyName* tcn) >> void Taxi::find(DemString* taxi_id,TaxiCompanyName* tcn) taxi company name "TownTaxi" << void Taxi::find(DemString* taxi_id,TaxiCompanyName* tcn) << void Taxi_List::find(DemString* taxi_id,TaxiCompanyName* tcn) << void TaxiCompany::find(DemString* taxi_id) << void TaxiCompany_List::find(DemString* taxi_id) << void SmallTravelSystem::find(DemString* taxi_id) << void SmallTravelSystem::query2() *** FINISHED ***