/* Objective_C Implementation of the Fruit Class: Fruit.m */

#import "Fruit.h"

@implementation Fruit : Object

/* Initialize a new fruit. */
-init
{
	[super init];			// do Object's init.  Now my own:
	[self setDiameter:1];		// init the diameter
	[self setColor:"green"]; 	// init the color
	return self;			// return the new instance
}

/* Action method for setting the color of the fruit. */
-takeColorFrom:sender
{
	[self setColor:[sender stringValue]];
	return self;
}

/* Set the color of the fruit. */
-setColor:(const char*)aColor
{
	color = aColor;
	return self;
}

/* Return the fruit's color. */
- (const char*)color
{
	return color;
}

/* Action method for setting the diameter of the fruit. */
-takeDiameterFrom:sender
{
	[self setDiameter:[sender intValue]];
	return self;
}

/* Set the fruit's diameter. */
-setDiameter: (int) aSize
{
	diameter = aSize;
	return self;
}

/* Return the fruit's diameter. */
- (int) diameter
{
	return diameter;
}

/* Tell the fruit to increase its diameter. */
- grow:sender
{
	[self setDiameter:([self diameter] + 1)];
	return self;
}

- displayValues:sender
{
	[colorDisplay setStringValue:color];
	[diameterDisplay setIntValue:diameter];
	return self;
}

@end
