#import "Inventory.h" @implementation Inventory -initWithRetail:(double)retail wholesale:(double)wholesale stock:(int)num color:(char*)color { myRetail = retail; myWholesale = wholesale; myNumInStock = num; color = strdup(color); return [super init]; } -(double)retail { return myRetail; } -(double)wholesale { return myWholesale; } -(int)numInStock { return myNumInStock; } -(const char*)color { return (const char*)myColor; } -(double)profit { return [self retail] - [self wholesale]; } -(int)compareTo:(id)rhs { if([self profit] < [rhs profit]) { return -1; } else if([self profit] > [rhs profit]) { return 1; } else { return 0; } } -(const char*)toString { snprintf(toString, 100, "Retail: $%.2f\nWholesale: $%.2f\nIn Stock: %i\nColor: %s\nProfit: $%.2f\n", [self retail], [self wholesale], [self numInStock], [self color], [self profit]); return (const char*)toString; } @end