Product.h:
#import <Foundation/Foundation.h>
@interface Product : NSObject
{
unsigned int valueOfProducts;
}
-(void) increaseValueOfProducts;
-(void) decreaseValueOfProducts;
-(void) resetValueOfProducts;
@end
Product.m:
#import "Product.h"
@implementation Product
-(void) increaseValueOfProducts {
valueOfProducts += 1;
}
-(void) decreaseValueOfProducts {
if ( valueOfProducts > 0 ) {
valueOfProducts -= 1;
}
}
-(void) resetValueOfProducts {
valueOfProducts = 0;
}
@end
main.m:
#import "Product.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
Product *sandwich = [[Product alloc] init];
Product *coke = [[Product alloc] init];
Product *chips = [[Product alloc] init];
Product *bread = [[Product alloc] init];
}
}
Now is my question: Is there any method, or something, that I can add so the user can add objects (so, new products) to the program he wants to keep track of?
I don't remember I have had that in the book, and I don't know what to search for. So I hope someone can help me with this.
Many thanks to anyone responding!