From 41f2d1f67129565732834d75624363113a7be8c1 Mon Sep 17 00:00:00 2001 From: John Richardson Date: Tue, 28 Jul 2015 21:59:49 -0400 Subject: [PATCH] Next! --- Objc-deli/FISAppDelegate.h | 9 ++++----- Objc-deli/FISAppDelegate.m | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Objc-deli/FISAppDelegate.h b/Objc-deli/FISAppDelegate.h index a833a69..919323b 100644 --- a/Objc-deli/FISAppDelegate.h +++ b/Objc-deli/FISAppDelegate.h @@ -12,10 +12,9 @@ @property (strong, nonatomic) UIWindow *window; -/* - - * Declare your methods here! - - */ + +- (NSString*)stringWithDeliLine:(NSMutableArray*)deliLine; +- (NSMutableArray*)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..b79fbbd 100644 --- a/Objc-deli/FISAppDelegate.m +++ b/Objc-deli/FISAppDelegate.m @@ -16,10 +16,28 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( return YES; } -/* - - * Define your methods here! - - */ +- (NSString*)stringWithDeliLine:(NSMutableArray*)deliLine { + if ([deliLine count] == 0) { + return @"The line is currently empty."; + } else { + NSString *lineList = @"The line is:"; + for (NSUInteger i = 0; i < [deliLine count]; i++) { + NSString *place = [NSString stringWithFormat: @"\n%lu. %@", i + 1, deliLine[i]]; + lineList = [lineList stringByAppendingString: place ]; + } + return lineList; + } +} + +- (NSMutableArray*)addName:(NSString*)name toDeliLine:(NSMutableArray*)deliLine{ + [deliLine addObject:name]; + return deliLine; +} + +- (NSString*)serveNextCustomerInDeliLine:(NSMutableArray*)deliLine{ + NSString *next = deliLine[0]; + [deliLine removeObjectAtIndex:0]; + return next; +} @end