Chapter #3 Examples in Oz %%%%%%%%%%%%%%%%%%% Chapter - 3 %%%%%%%%%%%%%%%%%%%%%% % 3.1 class PizzaD meth removeAnchovy(?$) raise abstract() end end meth topAnchovyWithCheese(?$) raise abstract() end end meth substituteAnchovyByCheese(?$) raise abstract() end end end class Crust from PizzaD meth init skip end meth removeAnchovy(?$) {New Crust init} end meth topAnchovyWithCheese(?$) {New Crust init} end meth substituteAnchovyByCheese(?$) {New Crust init} end end class Cheese from PizzaD feat P meth init(Pi) self.P = Pi end meth removeAnchovy(?$) {New Cheese init({self.P removeAnchovy($)})} end meth topAnchovyWithCheese(?$) {New Cheese init({self.P topAnchovyWithCheese($)})} end meth substituteAnchovyByCheese(?$) {New Cheese init({self.P substituteAnchovyByCheese($)})} end end class Olive from PizzaD feat P meth init(Pi) self.P = Pi end meth removeAnchovy(?$) {New Olive init({self.P removeAnchovy($)})} end meth topAnchovyWithCheese(?$) {New Olive init({self.P topAnchovyWithCheese($)})} end meth substituteAnchovyByCheese(?$) {New Olive init({self.P substituteAnchovyByCheese($)})} end end class Anchovy from PizzaD feat P meth init(Pi) self.P = Pi end meth removeAnchovy(?$) {self.P removeAnchovy($)} end meth topAnchovyWithCheese(?$) {New Cheese init({New Anchovy init({self.P topAnchovyWithCheese($)})})} end meth substituteAnchovyByCheese(?$) {New Cheese init({self.P substituteAnchovyByCheese($)})} end end class Sausage from PizzaD feat P meth init(Pi) self.P = Pi end meth removeAnchovy(?$) {New Sausage init({self.P removeAnchovy($)})} end meth topAnchovyWithCheese(?$) {New Sausage init({self.P topAnchovyWithCheese($)})} end meth substituteAnchovyByCheese(?$) {New Sausage init({self.P substituteAnchovyByCheese($)})} end end % 3.2 {Browse 2#{New Anchovy init( {New Olive init( {New Anchovy init( {New Anchovy init( {New Cheese init( {New Crust init})})})})})}} % 3.4 {Browse 4#{{New Anchovy init( {New Olive init( {New Anchovy init( {New Anchovy init( {New Cheese init( {New Crust init})})})})})} removeAnchovy($)}} % 3.5 {Browse 5#{{New Sausage init( {New Olive init( {New Anchovy init( {New Sausage init( {New Cheese init( {New Crust init})})})})})} removeAnchovy($)}} % 3.11 {Browse 11#{{New Anchovy init( {New Crust init})} removeAnchovy($)}} % 3.13 {Browse 13#{{New Anchovy init( {New Anchovy init( {New Crust init})})} removeAnchovy($)}} % 3.14 {Browse 14#{{New Olive init( {New Cheese init( {New Anchovy init( {New Anchovy init( {New Crust init})})})})} removeAnchovy($)}} % 3.15 local P in P = {New Cheese init( {New Anchovy init( {New Anchovy init( {New Crust init})})})} {Browse 15#{New Olive init({P removeAnchovy($)})}} end % 3.16 {Browse 16#{{New Cheese init( {New Anchovy init( {New Anchovy init( {New Crust init})})})} removeAnchovy($)}} local P in P = {New Anchovy init( {New Anchovy init( {New Crust init})})} {Browse 16#{New Cheese init({P removeAnchovy($)})}} end % 3.17 {Browse 17#{New Cheese init( {{New Anchovy init( {New Anchovy init( {New Crust init})})} removeAnchovy($)})}} % 3.18 {Browse 18#{{New Anchovy init( {New Anchovy init( {New Crust init})})} removeAnchovy($)}} % 3.22 {Browse 22#{New Cheese init( {{New Anchovy init( {New Cheese init( {New Crust init})})} removeAnchovy($)})}} % 3.23 local P in P = {New Anchovy init( {New Cheese init( {New Crust init})})} {Browse 23#{New Cheese init({P removeAnchovy($)})}} end % 3.24 {Browse 24#{New Cheese init( {{New Anchovy init( {New Cheese init( {New Crust init})})} removeAnchovy($)})}} % 3.25 {Browse 25#{{New Anchovy init( {New Cheese init( {New Crust init})})} removeAnchovy($)}} % 3.32 {Browse 32#{{New Olive init( {New Anchovy init( {New Cheese init( {New Anchovy init( {New Crust init})})})})} topAnchovyWithCheese($)}} % 3.34 {Browse 34#{{New Olive init( {New Cheese init( {New Sausage init( {New Crust init})})})} topAnchovyWithCheese($)}} % 3.37 {Browse 37#{{{New Olive init( {New Anchovy init( {New Cheese init( {New Anchovy init( {New Crust init})})})})} removeAnchovy($)} topAnchovyWithCheese($)}} % 3.38 {Browse 38#{{{New Olive init( {New Anchovy init( {New Cheese init( {New Anchovy init( {New Crust init})})})})} topAnchovyWithCheese($)} removeAnchovy($)}} % 3.41 {Browse 41#{{New Olive init( {New Anchovy init( {New Cheese init( {New Anchovy init( {New Crust init})})})})} substituteAnchovyByCheese($)}} % 3.47 class Spinach from PizzaD feat P meth init(Pi) self.P = Pi end meth removeAnchovy(?$) {New Spinach init({self.P removeAnchovy($)})} end meth topAnchovyWithCheese(?$) {New Spinach init({self.P topAnchovyWithCheese($)})} end meth substituteAnchovyByCheese(?$) {New Spinach init({self.P substituteAnchovyByCheese($)})} end end |