From 02725e976a09c8a06fb815c23de6f6b87d3504ec Mon Sep 17 00:00:00 2001 From: linda9009 Date: Fri, 4 Sep 2015 17:15:33 -0400 Subject: [PATCH] Tests passed, probably inefficient code --- Objc-deli/FISAppDelegate.h | 5 +++++ Objc-deli/FISAppDelegate.m | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Objc-deli/FISAppDelegate.h b/Objc-deli/FISAppDelegate.h index a833a69..4df5e4b 100644 --- a/Objc-deli/FISAppDelegate.h +++ b/Objc-deli/FISAppDelegate.h @@ -17,5 +17,10 @@ * Declare your methods here! */ +- (NSString *)stringWithDeliLine:(NSArray *)deliLine; + +- (void)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..abf3031 100644 --- a/Objc-deli/FISAppDelegate.m +++ b/Objc-deli/FISAppDelegate.m @@ -21,5 +21,27 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( * Define your methods here! */ +- (NSString *)stringWithDeliLine:(NSArray *)deliLine { + NSMutableString *queue = [[NSMutableString alloc]init]; + if ([deliLine count]==0) { + [queue appendString:(@"The line is currently empty.")]; + } + else {[queue appendString:(@"The line is:")]; + for (NSUInteger i=0; i < [deliLine count]; i++) { + [queue appendFormat:@"\n%lu. %@", i+1, deliLine[i]]; + }} + return queue; +} + + +- (void)addName:(NSString *)name toDeliLine:(NSMutableArray *)deliLine { + [deliLine addObject:name]; +} + +- (NSString *)serveNextCustomerInDeliLine:(NSMutableArray *)deliLine { + NSString *firstCustomer = deliLine[0]; + [deliLine removeObjectAtIndex:0]; + return firstCustomer; +} @end