My Solution to the Challenge

BNRStockHolding.h

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

#import <Foundation/Foundation.h>

@interface BNRStockHolding : NSObject

@property (nonatomic) float purchaseSharePrice;
@property (nonatomic) float currentSharePrice;
@property (nonatomic) int numberOfShares;
@property (nonatomic) NSString *stockName;

- (float)costInDollars; // purchaseSharePrice * numberOfShares
- (float)valueInDollars; // currentSharePrice * numberOfShares
- (float)gainOrLoss; //profit costInDollars - valueInDollars
- (void)addSelfToArray:(NSMutableArray *) theArray;

@end

BNRStockHolding.m

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

#import "BNRStockHolding.h"

@implementation BNRStockHolding


- (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);
}

- (void)addSelfToArray:(NSMutableArray *)theArray
{
    [theArray addObject:self];
}
@end

BNRForeignStockHolding.h

//
//  BNRForeignStockHolding.h
// 
//
//  Created by Adam G on 5/19/14.
//  
//

#import <Foundation/Foundation.h>
#import "BNRStockHolding.h"

@interface BNRForeignStockHolding : BNRStockHolding

@property (nonatomic) float conversionRate;

@end

BNRForeignStockHolding.m

[code]
//
// BNRForeignStockHolding.m
// Stocks
//
// Created by Adam G on 5/19/14.
//
//

#import “BNRForeignStockHolding.h”

@implementation BNRForeignStockHolding

  • (float)costInDollars; // (purchaseSharePrice * numberOfShares) * coversionRate
    {
    float totalPurchasePrice = [self purchaseSharePrice] * [self conversionRate];

    return (totalPurchasePrice * [self numberOfShares]);

}

  • (float)valueInDollars // currentSharePrice * numberOfShares
    {
    float currSharePriceValue = [self currentSharePrice] * [self conversionRate];

    return (currSharePriceValue * [self numberOfShares]);
    }

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

@end[/code]

main.m

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

#import <Foundation/Foundation.h>
#import "BNRStockHolding.h"
#import "BNRForeignStockHolding.h"

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

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