MySolution


#1

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

int main(int argc, const char * argv[]) {
@autoreleasepool {
// creating instances and allocating values
BNRStockHolding *firstStock = [[BNRStockHolding alloc]init];
[firstStock setNumberOfshare:40];
[firstStock setCurrentSharePrice:4.50];
[firstStock setPurchaseSharePrice:2.30];

    BNRStockHolding *secondStock = [[BNRStockHolding alloc]init];
    [secondStock setNumberOfshare:90];
    [secondStock setCurrentSharePrice:10.56];
    [secondStock setPurchaseSharePrice:12.19];
    
    BNRStockHolding *thirdStock = [[BNRStockHolding alloc]init];
    [thirdStock setNumberOfshare:210];
    [thirdStock setCurrentSharePrice:49.51];
    [thirdStock setPurchaseSharePrice:45.10];
    
    NSArray *stockArray = @[firstStock,secondStock,thirdStock];
    
    for(BNRStockHolding *n in stockArray){
        NSLog(@"values are %f , %d , %f",[n currentSharePrice],[n numberOfShare],[n purchaseSharePrice]);
    }
    
}
return 0;

}


#2

please have a look
correct me and suggestions please :slight_smile: