diff --git a/Choice.m b/Choice.m index 9fe7b7e..03942b8 100644 --- a/Choice.m +++ b/Choice.m @@ -42,6 +42,11 @@ - (MenuComponent *)initWithCoder:(NSCoder *)decoder basePrice = [decoder decodeObjectForKey:@"price"]; selected = [[decoder decodeObjectForKey:@"selected"] intValue]; isFree = [[decoder decodeObjectForKey:@"free"] boolValue]; + + if (!basePrice) + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"Choice failed to load properly from harddisk: \n%@" , self]); + } } return self; } diff --git a/Combo.m b/Combo.m index ed4c0f3..d7d0b00 100644 --- a/Combo.m +++ b/Combo.m @@ -68,6 +68,11 @@ - (MenuComponent *)initWithCoder:(NSCoder *)decoder strategy = [decoder decodeObjectForKey:@"strategy"]; + if ((!strategy) || (!listOfItemGroups)) + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"Combo failed to load properly from harddisk: \n%@" , self]); + } + } return self; } @@ -279,7 +284,8 @@ -(NSString *) descriptionWithIndent:(NSInteger) indentLevel NSMutableString *output = [[NSMutableString alloc] initWithCapacity:0]; - [output appendFormat:@"%@Combo:%\n",padString]; + [output appendFormat:@"%@Combo:\n",padString]; + [output appendFormat:@"%@Pricing strategy: %@ \n", padString, strategy]; [output appendString:[super descriptionWithIndent:indentLevel]]; [output appendFormat:@"%@ItemGroups:\n",padString]; diff --git a/ComboTrivialPricingStrategy.m b/ComboTrivialPricingStrategy.m index a65fd40..4d9d171 100644 --- a/ComboTrivialPricingStrategy.m +++ b/ComboTrivialPricingStrategy.m @@ -73,4 +73,9 @@ -(NSArray*)optimalPickFromItems:(NSArray*)items usingItemGroups:(NSArray*)groups return bestChoice; } +-(NSString *)description +{ + return @"Trivial pricing strategy"; +} + @end diff --git a/Item.m b/Item.m index e8f4a34..5305a4c 100644 --- a/Item.m +++ b/Item.m @@ -57,6 +57,11 @@ - (MenuComponent *)initWithCoder:(NSCoder *)decoder [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(optionAltered) name:OPTION_MODIFIED object:option]; } + if ((!basePrice) || (!options)) + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"Item failed to load properly from harddisk: \n%@" , self]); + } + } return self; } diff --git a/ItemGroup.m b/ItemGroup.m index bd14421..df23f81 100644 --- a/ItemGroup.m +++ b/ItemGroup.m @@ -82,6 +82,11 @@ - (MenuComponent *)initWithCoder:(NSCoder *)decoder listOfItems = [decoder decodeObjectForKey:@"list_of_items"]; satisfyingItem = [decoder decodeObjectForKey:@"satisfying_item"]; strategy = [decoder decodeObjectForKey:@"strategy"]; + + if ((!listOfItems) || (!satisfyingItem) || (!strategy)) + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"Combo failed to load properly from harddisk: \n%@" , self]); + } } return self; } @@ -176,6 +181,7 @@ - (NSString *) descriptionWithIndent:(NSInteger) indentLevel [output appendFormat:@"%@ItemGroup:%\n",padString]; [output appendString:[super descriptionWithIndent:indentLevel]]; + [output appendFormat:@"%@Pricing strategy: %@\n",padString,strategy]; [output appendFormat:@"%@Satisfied: %i\n",padString,[self satisfied]]; [output appendFormat:@"%@Satisfying item: %@\n",padString,[satisfyingItem descriptionWithIndent:(indentLevel + 1)]]; [output appendFormat:@"%@Items:\n",padString]; diff --git a/ItemGroupAbsolutePricing.m b/ItemGroupAbsolutePricing.m index 587af24..9c1eac9 100644 --- a/ItemGroupAbsolutePricing.m +++ b/ItemGroupAbsolutePricing.m @@ -52,4 +52,9 @@ -(Item*)optimalItem:(NSArray*)items{ return maxItem; } +-(NSString *)description +{ + return @"Group absolute pricing strategy"; +} + @end diff --git a/ItemGroupDiscountPricing.m b/ItemGroupDiscountPricing.m index ade489a..1264a57 100644 --- a/ItemGroupDiscountPricing.m +++ b/ItemGroupDiscountPricing.m @@ -42,4 +42,9 @@ -(Item*)optimalItem:(NSArray*)items{ return [items lastObject]; } +-(NSString *)description +{ + return @"Group discount pricing strategy"; +} + @end diff --git a/ItemGroupMultiplicativePricing.m b/ItemGroupMultiplicativePricing.m index 26c38a5..8ed3842 100644 --- a/ItemGroupMultiplicativePricing.m +++ b/ItemGroupMultiplicativePricing.m @@ -51,4 +51,9 @@ -(Item*)optimalItem:(NSArray*)items{ return maxItem; } +-(NSString *)description +{ + return @"Group multiplicative pricing strategy"; +} + @end diff --git a/ItemGroupTrivialPricing.m b/ItemGroupTrivialPricing.m index 859ce17..3cd9160 100644 --- a/ItemGroupTrivialPricing.m +++ b/ItemGroupTrivialPricing.m @@ -34,4 +34,9 @@ -(Item*)optimalItem:(NSArray*)items{ return [items lastObject]; } +-(NSString *)description +{ + return @"Trivial pricing strategy"; +} + @end diff --git a/Menu.m b/Menu.m index fc0bab9..256e754 100644 --- a/Menu.m +++ b/Menu.m @@ -86,6 +86,12 @@ - (MenuComponent *)initWithCoder:(NSCoder *)decoder { submenuList = [decoder decodeObjectForKey:@"submenu_list"]; comboList = [decoder decodeObjectForKey:@"combo_list"]; + + if ((!comboList) || (!submenuList)) + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"Menu failed to load properly from harddisk: \n%@" , self]); + } + } return self; } diff --git a/Option.m b/Option.m index f678d1a..414ce76 100644 --- a/Option.m +++ b/Option.m @@ -68,6 +68,10 @@ - (MenuComponent *)initWithCoder:(NSCoder *)decoder [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recalculate:) name:CHOICE_SELECTED_CHANGED object:newChoice]; } } + else + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"Option failed to load properly from harddisk: \n%@" , self]); + } } return self; diff --git a/Order.m b/Order.m index 2c8f090..b1971ca 100644 --- a/Order.m +++ b/Order.m @@ -70,6 +70,11 @@ - (MenuComponent *)initWithCoder:(NSCoder *)decoder creationDate = [decoder decodeObjectForKey:@"creation_date"]; mostRecentSubmitDate = [decoder decodeObjectForKey:@"most_recent_submit_date"]; + if ((!itemList) || (!comboList) || (!status) || (!orderIdentifier) || (!creationDate)) + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"Order failed to load properly from harddisk: \n%@" , self]); + } + } return self; } diff --git a/OrderManager.h b/OrderManager.h index fbc512f..00cf169 100644 --- a/OrderManager.h +++ b/OrderManager.h @@ -23,7 +23,6 @@ extern NSString* ORDER_MANAGER_NEEDS_REDRAW; { Order *thisOrder; Menu *thisMenu; - BOOL recalculating; } @property (readonly) Order *thisOrder; diff --git a/OrderManager.m b/OrderManager.m index deb8864..e09bafa 100644 --- a/OrderManager.m +++ b/OrderManager.m @@ -24,7 +24,6 @@ -(OrderManager *)init thisOrder = [[Order alloc] init]; thisMenu = [[Menu alloc] init]; - recalculating = NO; return self; } @@ -33,10 +32,14 @@ - (OrderManager *)initWithCoder:(NSCoder *)decoder { thisOrder = [decoder decodeObjectForKey:@"order"]; + thisMenu = [decoder decodeObjectForKey:@"menu"]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recalculate:) name:ORDER_MODIFIED object:thisOrder]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(redrawNotify:) name:ORDER_FAVORITE_MODIFIED object:thisOrder]; - thisMenu = [decoder decodeObjectForKey:@"menu"]; - recalculating = NO; + + if ((!thisOrder) || (!thisMenu)) + { + CLLog(LOG_LEVEL_ERROR, [NSString stringWithFormat: @"OrderManager failed to load properly from harddisk: \n%@" , self]); + } return self; }