The question is "Modify the print method for your Fraction class so that it takes an additional BOOL argument that indicates whether the fraction should be reduced for display. If it is to be reduced (that is if the argument is YES), be sure not to make any permanent changes to the fraction itself".
Okay, so I altered the print method, implemented the BOOL argument AND included the "shouldReduce" to make it one method.
- (void) print
{
BOOL shouldReduce;
shouldReduce = YES;
if (shouldReduce == YES)
{
int u = numerator;
int v = denominator;
int temp;
while (v!= 0) {
temp = u % v;
u = v;
v = temp;
}
numerator /= u;
denominator /= u;
}
NSLog(@"%i/%i", numerator, denominator);
}
When BOOL is YES, these are the results:
2012-03-02 09:12:03.518 Excercise 7_2[641:707] 1/2
2012-03-02 09:12:03.520 Excercise 7_2[641:707] +
2012-03-02 09:12:03.520 Excercise 7_2[641:707] 1/6
2012-03-02 09:12:03.521 Excercise 7_2[641:707] =
2012-03-02 09:12:03.521 Excercise 7_2[641:707] 2/3
2012-03-02 09:12:03.521 Excercise 7_2[641:707] -----------------------------
2012-03-02 09:12:03.522 Excercise 7_2[641:707] 1/2
2012-03-02 09:12:03.522 Excercise 7_2[641:707] -
2012-03-02 09:12:03.523 Excercise 7_2[641:707] 1/6
2012-03-02 09:12:03.523 Excercise 7_2[641:707] =
2012-03-02 09:12:03.523 Excercise 7_2[641:707] 1/3
2012-03-02 09:12:03.524 Excercise 7_2[641:707] -----------------------------
2012-03-02 09:12:03.524 Excercise 7_2[641:707] 1/2
2012-03-02 09:12:03.525 Excercise 7_2[641:707] *
2012-03-02 09:12:03.525 Excercise 7_2[641:707] 1/6
2012-03-02 09:12:03.525 Excercise 7_2[641:707] =
2012-03-02 09:12:03.526 Excercise 7_2[641:707] 1/12
2012-03-02 09:12:03.526 Excercise 7_2[641:707] -----------------------------
2012-03-02 09:12:03.526 Excercise 7_2[641:707] 1/2
2012-03-02 09:12:03.527 Excercise 7_2[641:707] /
2012-03-02 09:12:03.527 Excercise 7_2[641:707] 1/6
2012-03-02 09:12:03.527 Excercise 7_2[641:707] =
2012-03-02 09:12:03.528 Excercise 7_2[641:707] 3/1
Program ended with exit code: 0
When BOOL is NO, here are the results:
2012-03-02 09:19:33.697 Excercise 7_2[707:707] 1/2
2012-03-02 09:19:33.699 Excercise 7_2[707:707] +
2012-03-02 09:19:33.699 Excercise 7_2[707:707] 1/6
2012-03-02 09:19:33.700 Excercise 7_2[707:707] =
2012-03-02 09:19:33.700 Excercise 7_2[707:707] 8/12
2012-03-02 09:19:33.700 Excercise 7_2[707:707] -----------------------------
2012-03-02 09:19:33.701 Excercise 7_2[707:707] 1/2
2012-03-02 09:19:33.701 Excercise 7_2[707:707] -
2012-03-02 09:19:33.702 Excercise 7_2[707:707] 1/6
2012-03-02 09:19:33.702 Excercise 7_2[707:707] =
2012-03-02 09:19:33.703 Excercise 7_2[707:707] 4/12
2012-03-02 09:19:33.708 Excercise 7_2[707:707] -----------------------------
2012-03-02 09:19:33.714 Excercise 7_2[707:707] 1/2
2012-03-02 09:19:33.715 Excercise 7_2[707:707] *
2012-03-02 09:19:33.718 Excercise 7_2[707:707] 1/6
2012-03-02 09:19:33.719 Excercise 7_2[707:707] =
2012-03-02 09:19:33.719 Excercise 7_2[707:707] 1/12
2012-03-02 09:19:33.720 Excercise 7_2[707:707] -----------------------------
2012-03-02 09:19:33.721 Excercise 7_2[707:707] 1/2
2012-03-02 09:19:33.721 Excercise 7_2[707:707] /
2012-03-02 09:19:33.722 Excercise 7_2[707:707] 1/6
2012-03-02 09:19:33.722 Excercise 7_2[707:707] =
2012-03-02 09:19:33.723 Excercise 7_2[707:707] 6/2
Program ended with exit code: 0
If this isn't what was required or it's not right, please advise and be merciful to a woman who wishes she took up computer science instead of accounting

cheers
jacqueline