Skip to content

Commit

Permalink
Adds more error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jknielse committed Feb 10, 2012
1 parent e7be59b commit 77318d5
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Choice.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion Combo.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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];

Expand Down
5 changes: 5 additions & 0 deletions ComboTrivialPricingStrategy.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ -(NSArray*)optimalPickFromItems:(NSArray*)items usingItemGroups:(NSArray*)groups
return bestChoice;
}

-(NSString *)description
{
return @"Trivial pricing strategy";
}

@end
5 changes: 5 additions & 0 deletions Item.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions ItemGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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];
Expand Down
5 changes: 5 additions & 0 deletions ItemGroupAbsolutePricing.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ -(Item*)optimalItem:(NSArray*)items{
return maxItem;
}

-(NSString *)description
{
return @"Group absolute pricing strategy";
}

@end
5 changes: 5 additions & 0 deletions ItemGroupDiscountPricing.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ -(Item*)optimalItem:(NSArray*)items{
return [items lastObject];
}

-(NSString *)description
{
return @"Group discount pricing strategy";
}

@end
5 changes: 5 additions & 0 deletions ItemGroupMultiplicativePricing.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ -(Item*)optimalItem:(NSArray*)items{
return maxItem;
}

-(NSString *)description
{
return @"Group multiplicative pricing strategy";
}

@end
5 changes: 5 additions & 0 deletions ItemGroupTrivialPricing.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ -(Item*)optimalItem:(NSArray*)items{
return [items lastObject];
}

-(NSString *)description
{
return @"Trivial pricing strategy";
}

@end
6 changes: 6 additions & 0 deletions Menu.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions Option.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions Order.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion OrderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ extern NSString* ORDER_MANAGER_NEEDS_REDRAW;
{
Order *thisOrder;
Menu *thisMenu;
BOOL recalculating;
}

@property (readonly) Order *thisOrder;
Expand Down
9 changes: 6 additions & 3 deletions OrderManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ -(OrderManager *)init

thisOrder = [[Order alloc] init];
thisMenu = [[Menu alloc] init];
recalculating = NO;

return self;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 77318d5

Please sign in to comment.