home *** CD-ROM | disk | FTP | other *** search
- /*
- TEST.DO
- this file demonstrates method definition and parameter passing
- within dObject
- */
- #define MAXLOOP 10
-
- /*
- test class definition
-
- */
- inherit(Nil,X,["i"]);
- inherit(X,Y,["xx"]);
- inherit(Y,Z,["yy"]);
-
- /*
- test method definition
- X::doNothing is a private method of the "X" class
- */
- private X::doNothing(self)
- {
- ? "within do nothing";
- }
-
- /*
- convert a variable of type "X" to a String
- */
- method X::asString(self)
- {
- return(asString(slot(self,"i")));
- }
-
-
- /*
- demonstrate the precedence of a local variable over an argument
- */
- method X::test2(self,a)
- {
- a = 44;
- b = 1;
- c = 1;
- d = 1;
- ? "a is ",a," ",b," ",c," ",d;
- }
-
- method X::test(self,a)
- {
- ? "in test a is ",a;
- test2(self,132);
- ? "in test a is still ",a;
- ? self;
- }
-
- /*
- main program
- */
- a = 1;
- while(a < MAXLOOP) {
- ? a;
- b = new(Y,1,1,1);
- test(b,32);
- ? "in main a is ",a;
- a=a+1;
- }
-