Challenge

Create a new Foundation Command Line Tool called Stocks. Then create a class called BNRStockHolding to represent a stock that you have purchased. It will be a subclass of NSObject. For instance variables, it will have two floats named _purchaseSharePrice and _currentSharePrice and one int named _numberOfShares. Use properties to create accessor methods and instance variables. Create two other instance methods:

-​ ​(​f​l​o​a​t​)​c​o​s​t​I​n​D​o​l​l​a​r​s​;​ ​ ​/​/​ ​p​u​r​c​h​a​s​e​S​h​a​r​e​P​r​i​c​e​ ​*​ ​n​u​m​b​e​r​O​f​S​h​a​r​e​s​
-​ ​(​f​l​o​a​t​)​v​a​l​u​e​I​n​D​o​l​l​a​r​s​;​ ​/​/​ ​c​u​r​r​e​n​t​S​h​a​r​e​P​r​i​c​e​ ​*​ ​n​u​m​b​e​r​O​f​S​h​a​r​e​s​

In main(), fill an array with three instances of BNRStockHolding ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.