home *** CD-ROM | disk | FTP | other *** search
- /*Objective_C Implementation of the Banana Class: Banana.m*/
-
- #import "Banana.h"
-
- @implementation Banana : Fruit
-
- /* Initialize a new banana object. */
- -init
- {
- [super init]; //Do Fruit's init. Now my own.
- [[[self setLength:5] setDiameter:2] setColor:"yellow"]; // initialize
- return self; // return the new instance
- }
-
- /* Tell a banana to increase its diameter and length. */
- -grow
- {
- [self setDiameter:([self diameter] + 1)];
- [self setLength:([self length] + 2)];
- return self;
- }
-
- /* Set the length instance variable. */
- -setLength:(int) aSize
- {
- length = aSize;
- return self;
- }
-
- /* Return the value of the length instance variable. */
- - (int) length
- {
- return length;
- }
-
-
- @end
-