#import <Foundation/Foundation.h>
@interface StockHolding : NSObject
{
float purchaseSharePrice;
float currentSharePrice;
int numberOfShares;
}
@property float purchaseSharePrice;
@property float currentSharePrice;
@property int numberOfShares;
- (float)costInDollars;
- (float)valueInDollars;
@end
#import "StockHolding.h"
@implementation StockHolding
@synthesize purchaseSharePrice, currentSharePrice, numberOfShares;
- (float)costInDollars
{
return purchaseSharePrice * numberOfShares;
}
- (float)valueInDollars
{
return currentSharePrice * numberOfShares;
}
@end
#import <Foundation/Foundation.h>
#import "StockHolding.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSArray *threeobjects = [NSArray arrayWithObjects:purchaseSharePrice, currentSharePrice, numberOfShares, nil];
}
return 0;
}
StockHolding* obj = [StockHolding new];
obj.purchaseSharePrice = 1;
obj.currentSharePrice = 2;
obj.numberOfShares = 3;
NSArray* fourobjects = @[@(obj.purchaseSharePrice), @(obj.currentSharePrice),
@(obj.numberOfShares), @([obj costInDollars])];