home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / DATABASE / DO1BETA.ZIP / TEST.DO < prev    next >
Text File  |  1991-08-24  |  915b  |  65 lines

  1. /*
  2.     TEST.DO
  3.     this file demonstrates method definition and parameter passing
  4.     within dObject
  5. */
  6. #define MAXLOOP 10
  7.  
  8. /*
  9.     test class definition
  10.  
  11. */
  12. inherit(Nil,X,["i"]);
  13. inherit(X,Y,["xx"]);
  14. inherit(Y,Z,["yy"]);
  15.  
  16. /*
  17.     test method definition
  18.     X::doNothing is a private method of the "X" class
  19. */
  20. private X::doNothing(self)
  21. {
  22.     ? "within do nothing";
  23. }
  24.  
  25. /*
  26.     convert a variable of type "X" to a String
  27. */
  28. method X::asString(self)
  29. {
  30.     return(asString(slot(self,"i")));
  31. }
  32.  
  33.  
  34. /*
  35.     demonstrate the precedence of a local variable over an argument
  36. */
  37. method X::test2(self,a)
  38. {
  39.     a = 44;
  40.     b = 1;
  41.     c = 1;
  42.     d = 1;
  43.     ? "a is ",a," ",b," ",c," ",d;
  44. }
  45.  
  46. method X::test(self,a)
  47. {
  48.     ? "in test a is ",a;
  49.     test2(self,132);
  50.     ? "in test a is still ",a;
  51.     ? self;
  52. }
  53.  
  54. /*
  55.     main program
  56. */
  57. a = 1;
  58. while(a < MAXLOOP) {
  59.     ? a;
  60.     b = new(Y,1,1,1);
  61.     test(b,32);
  62.     ? "in main a is ",a;
  63.     a=a+1;
  64. }
  65.