0
Big Nerd Ranch의 Objective-C 가이드를 사용하고 있으며 내가 만든 클래스의 모든 항목을 표시하는 데 문제가 있습니다. 더 많은 참고 자료는 제 17 장의 주식에 대한 도전이다. 이 문제에 대한 다른 질문이 있다는 것을 알고 있지만 다른 모든 문제에 대한 수정 된 코드를 확인한 후에도 문제가 계속됩니다. 어떤 이유로 페이스 북 비용 만 표시됩니다. 여기에 내 작품이다 : StockHolding.h수업 중 몇 가지 항목 만 표시되고 있습니까?
#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
StockHolding.m
#import "StockHolding.h"
@implementation StockHolding
@synthesize purchaseSharePrice;
@synthesize currentSharePrice;
@synthesize numberOfShares;
-(float)costInDollars
{
return numberOfShares*purchaseSharePrice;
}
-(float)valueInDollars
{
return numberOfShares*currentSharePrice;
}
@end
main.m
도와#import <Foundation/Foundation.h>
#import "StockHolding.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
StockHolding *apple, *google, *facebook = [[StockHolding alloc] init];
[apple setNumberOfShares:43];
[apple setCurrentSharePrice:738.96];
[apple setPurchaseSharePrice:80.02];
[google setNumberOfShares:12];
[google setCurrentSharePrice:561.07];
[google setPurchaseSharePrice:600.01];
[facebook setNumberOfShares:5];
[facebook setCurrentSharePrice:29.33];
[facebook setPurchaseSharePrice:41.21];
NSLog(@"%.2f.", [apple costInDollars]);
NSLog(@"%.2f.", [google costInDollars]);
NSLog(@"%.2f.", [facebook costInDollars]);
}
return 0;
}
감사합니다!
감사 :와
는보십시오. 큰 도움이됩니다! –