I am a beginner in objective-c coding, so please take it easy on me. Xcode is saying I have an error, in red, saying it expected ( or ) identifiers...any solutions? Also, is it necessary to have both of the items bolded in green?
----------
This is also coming out of a book, so any reason to why I am doing what I am doing I cannot answer for this is the code the author wanted me to write.
Code:
[COLOR="Lime"]#include <stdio.h>[/COLOR]
//Class Name and it's superclass (Budget, NSObject respectively)
//The inherits all of the superclass's methods as well as the ones in code
[COLOR="red"]@interface Budget : NSObject {[/COLOR]
//Instance Variables: declaration of variables
float exchangeRate;
double budget;
double exchangeTransaction;
}
//Methods: the function of the class
- (void) createBudget: (double) aBudget withExchangeRate: (float) anExchangeRate;
[COLOR="Red"]- (void) spendDollars: (double) dollars;
- (void) chargeForeignCurrency: (double) foreignCurrency;[/COLOR]
[COLOR="red"]@end[/COLOR]
@implementation Budget
- (void) createBudget: (double) aBudget withExchangeRate: (float) anExchangeRate
{
exchangeRate = anExchangeRate;
budget = aBudget;
}
- (void) spendDollars: (double) dollars {
budget -= dollars;
printf("Converting %.2f US dollars into foreign currency leaves $%.2f", dollars, budget);
}
- (void) chargeForeignCurrency: (double) foreignCurrency {
exchangeTransaction = foreignCurrency * exchangeRate;
budget -= exchangeTransaction;
printf("Charging %2f in foreign currency leaves $%.2f", foreignCurrency, budget);
}
@end
[COLOR="lime"]#include <stdio.h>[/COLOR]
int main(int argc, const char * argv[])
{
double numberDollarsEurope = 100;
double numberEuros = 100;
double numberDollarsEngland = 100;
double numberPounds = 100;
Budget *europeBudget = [Budget new];
[europeBudget createBudget: 1000.00 withExchangeRate 1.2500];
[europeBudget spendDollars:numberDollarsEurope];
[europeBudget chargeForeignCurrency:numberEuros];
Budget *englandBudget = [Budget new];
[englandBudget createBudget: 2000.00 withExchangeRate 1.5000];
[englandBudget spendDollars: numberDollarsEngland];
[englandBudget chargeForeignCurrency:numberPounds];
return 0;
}
----------
This is also coming out of a book, so any reason to why I am doing what I am doing I cannot answer for this is the code the author wanted me to write.