home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / OOP_Course / Labs / Fruit / Solution / Banana.m < prev    next >
Encoding:
Text File  |  1993-01-18  |  688 b   |  38 lines

  1. /*Objective_C Implementation of the Banana Class: Banana.m*/
  2.  
  3. #import "Banana.h"
  4.  
  5. @implementation Banana : Fruit
  6.  
  7. /* Initialize a new banana object. */
  8. -init
  9. {
  10.     [super init];    //Do Fruit's init.  Now my own.
  11.     [[[self setLength:5] setDiameter:2] setColor:"yellow"]; // initialize
  12.     return self;     // return the new instance
  13. }
  14.  
  15. /* Tell a banana to increase its diameter and length. */
  16. -grow
  17. {
  18.     [self setDiameter:([self diameter] + 1)];
  19.     [self setLength:([self length] + 2)];
  20.     return self;
  21. }
  22.  
  23. /* Set the length instance variable. */
  24. -setLength:(int) aSize
  25. {
  26.     length = aSize;
  27.     return self;
  28. }
  29.  
  30. /* Return the value of the length instance variable. */ 
  31. - (int) length
  32. {
  33.     return length;
  34. }
  35.  
  36.  
  37. @end
  38.