From ca3bde209cb557a428d4402b5a509c2bd8122a27 Mon Sep 17 00:00:00 2001 From: joelconnects Date: Mon, 7 Sep 2015 14:15:12 -0400 Subject: [PATCH] deli counter tests passing --- Objc-deli/FISAppDelegate.h | 5 +++++ Objc-deli/FISAppDelegate.m | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/Objc-deli/FISAppDelegate.h b/Objc-deli/FISAppDelegate.h index a833a69..d13e964 100644 --- a/Objc-deli/FISAppDelegate.h +++ b/Objc-deli/FISAppDelegate.h @@ -18,4 +18,9 @@ */ +- (NSString *)stringWithDeliLine:(NSArray *)deliLine; +- (NSString *)addName:(NSString *)name toDeliLine:(NSMutableArray *)deliLine; +- (NSString *)serveNextCustomerInDeliLine:(NSMutableArray *)deliLine; + + @end diff --git a/Objc-deli/FISAppDelegate.m b/Objc-deli/FISAppDelegate.m index 8a5dea5..3863d42 100644 --- a/Objc-deli/FISAppDelegate.m +++ b/Objc-deli/FISAppDelegate.m @@ -22,4 +22,45 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( */ +- (NSString *)stringWithDeliLine:(NSArray *)deliLine { + + NSString *deliLineStatus; + + if ([deliLine count] == 0) { + deliLineStatus = @"The line is currently empty."; + } else { + + deliLineStatus = @"The line is:"; + for (NSUInteger i = 0; i < [deliLine count]; i++) { + + NSUInteger deliNumber = i + 1; + NSString *deliNumberString = [@(deliNumber) stringValue]; + + deliLineStatus = [deliLineStatus stringByAppendingString:@"\n"]; + deliLineStatus = [deliLineStatus stringByAppendingString:deliNumberString]; + deliLineStatus = [deliLineStatus stringByAppendingString:@". "]; + deliLineStatus = [deliLineStatus stringByAppendingString:deliLine[i]]; + + } + } + + return deliLineStatus; + +} + +- (NSString *)addName:(NSString *)name toDeliLine:(NSMutableArray *)deliLine { + + [deliLine addObject:name]; + + return name; +} + +- (NSString *)serveNextCustomerInDeliLine:(NSMutableArray *)deliLine { + + NSString *nextCustomer = [deliLine objectAtIndex:0]; + [deliLine removeObjectAtIndex:0]; + + return nextCustomer; +} + @end