home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / AlexNeXTSTEPSource / Source / Chapter3_OOD / ShapeArea / Square.m < prev   
Encoding:
Text File  |  1993-04-13  |  524 b   |  36 lines

  1. #import "Square.h"
  2.  
  3. @implementation Square
  4.  
  5. // override method to print the width and height
  6. // as well as the area
  7. -(float)calcArea
  8. {
  9.     // use self to refer to the same object
  10.     // that received the calcArea method
  11.     [self printHeight];
  12.     [self printWidth];
  13.     // use super to access the superclass'
  14.     // implementation
  15.     return [super calcArea];
  16. }
  17.  
  18. -printHeight
  19. {
  20.     printf("The height is %.2f\n", height);
  21.     return self;
  22. }
  23.  
  24. -printWidth
  25. {
  26.     printf("The width is %.2f\n", width);
  27.     return self;
  28. }
  29.  
  30. -free
  31. {
  32.     return [super free];
  33. }
  34.  
  35. @end
  36.