//
// coins.m
// Coin Jar
//
// Created by Ness on 6/4/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "coins.h"
@implementation coins
- (id)init
{
NSNumber *temp = [[NSNumber alloc] initWithInt:0];
return [self initWithDollars:temp
Quarters:temp
Dimes:temp
Nickels:temp
Pennies:temp];
}
- (id)initWithDollars:(NSNumber *)dollars
Quarters:(NSNumber *)quarters
Dimes:(NSNumber *)dimes
Nickels:(NSNumber *)nickels
Pennies:(NSNumber *)pennies
{
if (![super init])
return nil;
[Dol init];
Dol = dollars;
[Nic init];
Nic = nickels;
[Qua init];
Qua = quarters;
[Dim init];
Dim=dimes;
[Pen init];
Pen=pennies;
return self;
}
- (void)incDollars:(NSNumber*)incValue
{
int temp;
temp = [Dol intValue];
temp=temp+[incValue intValue];
Dol = [NSNumber numberWithInt:temp];
}
- (void)incQuarters:(NSNumber *)incValue
{
int temp;
temp = [Qua intValue];
temp=temp+[incValue intValue];
Qua = [NSNumber numberWithInt:temp];
}
- (void)incDimes:(NSNumber *)incValue
{
int temp;
temp = [Dim intValue];
temp=temp+[incValue intValue];
Dim = [NSNumber numberWithInt:temp];
}
- (void)incNickels:(NSNumber *)incValue
{
int temp;
temp = [Nic intValue];
temp=temp+[incValue intValue];
Nic = [NSNumber numberWithInt:temp];
}
- (void)incPennies:(NSNumber *)incValue
{
int temp;
temp = [Pen intValue];
temp=temp+[incValue intValue];
Pen = [NSNumber numberWithInt:temp];
}
- (void)decDollars:(NSNumber *)decValue
{
int temp;
temp = [Dol intValue];
temp = temp - [decValue intValue];
if (temp < 0)
temp = 0;
Dol= [NSNumber numberWithInt:temp];
}
- (void)decQuarters:(NSNumber *)decValue
{
int temp;
temp = [Qua intValue];
temp = temp - [decValue intValue];
if (temp < 0)
temp = 0;
Qua= [NSNumber numberWithInt:temp];
}
- (void)decDimes:(NSNumber *)decValue
{
int temp;
temp = [Dim intValue];
temp = temp - [decValue intValue];
if (temp < 0)
temp = 0;
Dim= [NSNumber numberWithInt:temp];
}
- (void)decNickels:(NSNumber *)decValue
{
int temp;
temp = [Nic intValue];
temp = temp - [decValue intValue];
if (temp < 0)
temp = 0;
Nic= [NSNumber numberWithInt:temp];
}
- (void)decPennies:(NSNumber *)decValue
{
int temp;
temp = [Pen intValue];
temp = temp - [decValue intValue];
if (temp < 0)
temp = 0;
Pen= [NSNumber numberWithInt:temp];
}
- (void)incAllDollars:(NSNumber *)dollars
Quarters:(NSNumber *)quarters
Dimes:(NSNumber *)dimes
Nickels:(NSNumber *)nickels
Pennies:(NSNumber *)pennies
{
[self incDollars:dollars];
[self incQuarters:quarters];
[self incDimes:dimes];
[self incNickels:nickels];
[self incPennies:pennies];
}
- (void)decAllDollars:(NSNumber *)dollars
Quarters:(NSNumber *)quarters
Dimes:(NSNumber *)dimes
Nickels:(NSNumber *)nickels
Pennies:(NSNumber *)pennies
{
[self decDollars:dollars];
[self decQuarters:quarters];
[self decDimes:dimes];
[self decNickels:nickels];
[self decPennies:pennies];
}
- (NSString *)printDollarNumber
{
return [Dol stringValue];
}
- (NSString *)printDollarValue
{
float temp = 1 * [Dol floatValue];
NSString* tempStr=[[NSString alloc] initWithFormat:@"$ %.02f",temp];
return tempStr;
}
- (NSString *)printQuarterNumber
{
return [Qua stringValue];
}
- (NSString *)printQuarterValue
{
float temp = .25 * [Qua floatValue];
NSString* tempStr=[[NSString alloc] initWithFormat:@"$ %.02f",temp];
return tempStr;
}
- (NSString *)printDimeNumber
{
return [Dim stringValue];
}
- (NSString *)printDimeValue
{
float temp = .1 * [Dim floatValue];
NSString* tempStr=[[NSString alloc] initWithFormat:@"$ %.02f",temp];
return tempStr;
}
- (NSString *)printNickelNumber
{
return [Nic stringValue];
}
- (NSString *)printNickelValue
{
float temp = .05 * [Nic floatValue];
NSString* tempStr=[[NSString alloc] initWithFormat:@"$ %.02f",temp];
return tempStr;
}
- (NSString *)printPennyNumber
{
return [Pen stringValue];
}
- (NSString *)printPennyValue
{
float temp = .01 * [Pen floatValue];
NSString* tempStr=[[NSString alloc] initWithFormat:@"$ %.02f",temp];
return tempStr;
}
- (NSString *)PrintTotalValue
{
float temp = 1 * [Dol floatValue];
temp = temp + .25 * [Qua floatValue];
temp = temp + .10 * [Dim floatValue];
temp = temp + .05 * [Nic floatValue];
temp = temp + .01 * [Pen floatValue];
NSString* tempStr=[[NSString alloc] initWithFormat:@"$ %.02f",temp];
return tempStr;
}
@end