My Solution


#1

Header File

//  BNRStockHolding.h
//  Stocks
//
//  Created by Adam G on 5/17/14.
//

#import <Foundation/Foundation.h>

@interface BNRStockHolding : NSObject

{
    float _purchaseSharePrice;
    float _currentSharePrice;
    int _numberOfShares;
    NSString *_stockName;
}

// Getter methods
- (float)purchaseSharePrice;
- (float)currentsharePrice;
- (int)numberOfShares;
- (NSString *)stockName;


// Setter methods
- (void)setPurchaseSharePrice:(float)mySharePrice;
- (void)setCurrentSharePrice:(float)myCurrentSharePrice;
- (void)setNumberOfShares:(int)num;
- (void)setStockName:(NSString *)name;


- (float)costInDollars; // purchaseSharePrice * numberOfShares
- (float)valueInDollars; // currentSharePrice * numberOfShares
- (float)gainOrLoss; //profit costInDollars - valueInDollars


@end

Implementation File


//
//  BNRStockHolding.m
//  Stocks
//
//  Created by Adam G on 5/17/14.
//

#import "BNRStockHolding.h"

@implementation BNRStockHolding

// Getter methods
- (float)purchaseSharePrice
{
    return _purchaseSharePrice;
}

- (float)currentsharePrice
{
    return _currentSharePrice;
}

- (int)numberOfShares
{
    return _numberOfShares;
}

- (NSString *)stockName
{
    return _stockName;
}


// Setter methods

- (void)setStockName:(NSString *)name
{
    _stockName = name;
}


- (void)setPurchaseSharePrice:(float)mySharePrice
{
    _purchaseSharePrice = mySharePrice;
}
- (void)setCurrentSharePrice:(float)myCurrentSharePrice;
{
    _currentSharePrice = myCurrentSharePrice;
}
- (void)setNumberOfShares:(int)num;
{
    _numberOfShares = num;
}

- (float)costInDollars; // purchaseSharePrice * numberOfShares
{
    float purSharePrice = [self purchaseSharePrice];
    int numOfShares = [self numberOfShares];
    
    return (purSharePrice * numOfShares);
}
- (float)valueInDollars; // currentSharePrice * numberOfShares
{
    float curSharePrice = [self currentsharePrice];
    int numOfShares = [self numberOfShares];
    
    return (curSharePrice * numOfShares);
}

- (float)gainOrLoss
{
    float profit = [self valueInDollars] - [self costInDollars];
    return (profit);
}
@end

Main.m file

[code]//
// main.m
// Stocks
//
// Created by Adam G on 5/17/14.
//

#import <Foundation/Foundation.h>
#import “BNRStockHolding.h”

int main(int argc, const char * argv[])
{

@autoreleasepool {
    
    BNRStockHolding *idev = [[BNRStockHolding alloc] init];
    BNRStockHolding *mptv = [[BNRStockHolding alloc]init];
    BNRStockHolding *txrh = [[BNRStockHolding alloc] init];
    
    [idev setPurchaseSharePrice:2.30];
    [idev setCurrentSharePrice:4.50];
    [idev setNumberOfShares:40];
    [idev setStockName:@("IDEV")];
    
    [mptv setPurchaseSharePrice:12.19];
    [mptv setCurrentSharePrice:10.56];
    [mptv setNumberOfShares:90];
    [mptv setStockName:@("MPTV")];
    
    [txrh setPurchaseSharePrice:45.10];
    [txrh setCurrentSharePrice:49.51];
    [txrh setNumberOfShares:210];
    [txrh setStockName:@("TXRH")];
    
    NSMutableArray *stocks = [NSMutableArray array];
    [stocks addObject:idev];
    [stocks addObject:mptv];
    [stocks addObject:txrh];
    
    
    for (BNRStockHolding *stockHolding in stocks)
    {
        
        NSLog(@"The Stock Ticker Symbol is %@", [stockHolding stockName]);
        NSLog(@"The Purchase Price %.2f", [stockHolding purchaseSharePrice]);
        NSLog(@"The Current Share Price %.2f", [stockHolding currentsharePrice]);
        NSLog(@"The Number of Shares Purchased %d\n", [stockHolding numberOfShares]);
        NSLog(@"The Total Cost in Dollars %.2f", [stockHolding costInDollars]);
        NSLog(@"The Current Dollar Value %.2f", [stockHolding valueInDollars]);
        NSLog(@"Gain or Loss value %.2f\n\n\r", [stockHolding gainOrLoss]);
        
        
    }
    
    
}
return 0;

}

[/code]