From 322db899d55114133a400fd704624705e691a993 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Sat, 27 Jun 2015 12:02:16 -0400 Subject: [PATCH 01/16] first commit --- TodoList/TodoList/main.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 187be40..1cb0ce3 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -5,7 +5,7 @@ // Created by Michael Kavouras on 6/25/15. // Copyright (c) 2015 Mike Kavouras. All rights reserved. // - +// i made a change #import int main(int argc, const char * argv[]) { From 784623a9b7e6b027caf3e41a775efba098d6ffcf Mon Sep 17 00:00:00 2001 From: Eric Sze Date: Sat, 27 Jun 2015 12:04:47 -0400 Subject: [PATCH 02/16] edit --- TodoList/TodoList/main.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 1cb0ce3..187be40 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -5,7 +5,7 @@ // Created by Michael Kavouras on 6/25/15. // Copyright (c) 2015 Mike Kavouras. All rights reserved. // -// i made a change + #import int main(int argc, const char * argv[]) { From 366d0502eebf6ad3669a673e651fbf9fbb347a86 Mon Sep 17 00:00:00 2001 From: Eric Sze Date: Sat, 27 Jun 2015 15:16:14 -0400 Subject: [PATCH 03/16] new edits --- TodoList/TodoList/main.m | 42 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 187be40..1677b8a 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -8,10 +8,48 @@ #import +@interface Manager: NSObject + +@property (nonatomic) NSMutableArray *lists; + +//-(void)arr:(NSMutableArray) +//-(void)print; + +@end + +@interface list: NSObject +@end + +@interface item: NSObject +@end + +@implementation Manager + + + +- (void)print { + NSLog(@"\n1)Add item to list\n2)Remove item from list\n3)Create new list"); +} + +@end + int main(int argc, const char * argv[]) { @autoreleasepool { - // insert code here... - NSLog(@"Hello, World!"); + + NSMutableArray *arr = [[NSMutableArray alloc] init]; + Manager *m = [[Manager alloc] init]; + [m print]; + if (print == buf) { + NSLog(@"%s", buf); + } +// NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:3]; +// for (int i = 0; i < 3; i++) { + char buf[100]; + scanf("%s", buf); +// NSString *str = [NSString stringWithCString:buf encoding:NSASCIIStringEncoding]; +// [arr addObject:str]; +// } + } return 0; } From ea875e747d2b6116fe24f698c07729ec34689fc0 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Sun, 28 Jun 2015 08:39:55 -0400 Subject: [PATCH 04/16] made some changes --- TodoList/TodoList/main.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 1677b8a..964fd5a 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -12,6 +12,9 @@ @interface Manager: NSObject @property (nonatomic) NSMutableArray *lists; +- (void)addItem; +- (void)removeItem; + //-(void)arr:(NSMutableArray) //-(void)print; @@ -25,7 +28,14 @@ @interface item: NSObject @implementation Manager - +- (NSMutableArray *)lists { + NSLog(@"What would you like to do?"); + //lists options: new list, add item, remove item, mark item done, mark item done + + if () { + <#statements#> + } +} - (void)print { NSLog(@"\n1)Add item to list\n2)Remove item from list\n3)Create new list"); From 9a43dea232e6bd8b93f4ab74dd14b774b9502f70 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Sun, 28 Jun 2015 09:27:30 -0400 Subject: [PATCH 05/16] added to interface --- TodoList/TodoList/main.m | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 964fd5a..00f7e4d 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -10,33 +10,50 @@ @interface Manager: NSObject -@property (nonatomic) NSMutableArray *lists; +@property (nonatomic) NSMutableArray *listTopic; + +- (void)createListCategory; +- (void)removeListCategory; +- (void)editListCategory; +- (void)listCategoryDone; +- (void)listCategoryActive; +- (void)listCategoryPriority; -- (void)addItem; -- (void)removeItem; -//-(void)arr:(NSMutableArray) -//-(void)print; @end -@interface list: NSObject +@interface TaskList: NSObject @end -@interface item: NSObject +@interface Item: NSObject @end @implementation Manager -- (NSMutableArray *)lists { +- (NSMutableArray *)listTopic { NSLog(@"What would you like to do?"); //lists options: new list, add item, remove item, mark item done, mark item done - if () { - <#statements#> + if (!_listTopic) { + _listTopic = [[NSMutableArray alloc]init]; } + return _listTopic; //if the item is not a list topic, then create one +} + +- (void)addItem: (NSString *)chore { + NSLog(@"%@", chore); +} + +- (void)removeItem: (NSString *)chore { + } + + + + + - (void)print { NSLog(@"\n1)Add item to list\n2)Remove item from list\n3)Create new list"); } From cdc4b3c36960cfa207b5283ff9c41825762ccb2a Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Sun, 28 Jun 2015 21:06:28 -0400 Subject: [PATCH 06/16] added methods --- TodoList/TodoList/main.m | 131 ++++++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 36 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 00f7e4d..dc07f6e 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -8,75 +8,134 @@ #import +@class Manager; +@class List; +@class Item; + @interface Manager: NSObject -@property (nonatomic) NSMutableArray *listTopic; +@property (nonatomic) NSMutableArray *lists; -- (void)createListCategory; -- (void)removeListCategory; -- (void)editListCategory; -- (void)listCategoryDone; -- (void)listCategoryActive; -- (void)listCategoryPriority; +- (void)start; +@end +@interface List: NSObject -@end +@property (nonatomic) NSMutableArray *items; + +// Calls scanf and creates a new Item and adds that item to items array +-(Item *)scanItem; -@interface TaskList: NSObject @end @interface Item: NSObject + +@property (nonatomic) NSString *content; + @end + @implementation Manager -- (NSMutableArray *)listTopic { - NSLog(@"What would you like to do?"); - //lists options: new list, add item, remove item, mark item done, mark item done - - if (!_listTopic) { - _listTopic = [[NSMutableArray alloc]init]; +- (List *)createList +{ + if (!self.lists) { + self.lists = [[NSMutableArray alloc] init]; } - return _listTopic; //if the item is not a list topic, then create one + + List *newList = [[List alloc] init]; + [self.lists addObject:newList]; + return newList; } -- (void)addItem: (NSString *)chore { - NSLog(@"%@", chore); +-(int)showMenu +{ + printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n"); + + int input; + scanf("%d", &input); + + return input; +} + +-(void)printLists +{ + // For each list in self.lists + for (List *list in self.lists) { + printf("%s\n", [[NSString stringWithFormat:@"%@", list] cStringUsingEncoding:NSUTF8StringEncoding]); + } } -- (void)removeItem: (NSString *)chore { +-(void)start +{ + while (true) { + int menuPicked = [self showMenu]; + + if (menuPicked == 0) { + break; + } + else if (menuPicked == 1){ + List *list = [self createList]; + while (true) { + Item *newItem = [list scanItem]; + if (!newItem) break; + } + } + else if (menuPicked == 2) { + [self printLists]; + } + } } +@end +@implementation List +-(NSString *)description +{ + // What gets printed when the object gets printed + return [NSString stringWithFormat:@"%@", self.items]; +} +-(Item *)scanItem +{ + if (!self.items) { + self.items = [[NSMutableArray alloc] init]; + } + + printf("What would you list to add to your list?\n"); + + char input[1024]; + scanf("%s", input); + if (strcmp(input, "0") == 0) { + return nil; + } + + Item *item = [[Item alloc] init]; + item.content = @(input); + + [self.items addObject:item]; + + return item; +} +@end +@implementation Item -- (void)print { - NSLog(@"\n1)Add item to list\n2)Remove item from list\n3)Create new list"); +-(NSString *)description +{ + return self.content; } @end int main(int argc, const char * argv[]) { @autoreleasepool { - - NSMutableArray *arr = [[NSMutableArray alloc] init]; - Manager *m = [[Manager alloc] init]; - [m print]; - if (print == buf) { - NSLog(@"%s", buf); - } -// NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:3]; -// for (int i = 0; i < 3; i++) { - char buf[100]; - scanf("%s", buf); -// NSString *str = [NSString stringWithCString:buf encoding:NSASCIIStringEncoding]; -// [arr addObject:str]; -// } - + + Manager *manager = [[Manager alloc] init]; + [manager start]; } return 0; } From 8c40b02f334c91479cfaa4aee8a9507dac1640d9 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Mon, 29 Jun 2015 18:34:46 -0400 Subject: [PATCH 07/16] add 3rd choice --- TodoList/TodoList/main.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index dc07f6e..311d7f5 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -49,9 +49,10 @@ - (List *)createList return newList; } + -(int)showMenu { - printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n"); + printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n"); int input; scanf("%d", &input); @@ -67,6 +68,12 @@ -(void)printLists } } +//-(List *)deleteContent +//{ +// +//} + + -(void)start { @@ -86,6 +93,14 @@ -(void)start else if (menuPicked == 2) { [self printLists]; } + else if (menuPicked == 3) { + printf("What would you like to remove?"); + + + int deleteContent; + scanf("%d", &deleteContent); + + } } } @@ -105,7 +120,7 @@ -(Item *)scanItem self.items = [[NSMutableArray alloc] init]; } - printf("What would you list to add to your list?\n"); + printf("What would you like to add to your list?\n"); char input[1024]; scanf("%s", input); From 9e76865dcc77e4b4b2d64cef098514554738e8b9 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Mon, 29 Jun 2015 20:09:06 -0400 Subject: [PATCH 08/16] added remove item --- TodoList/TodoList.xcodeproj/project.pbxproj | 19 +++ TodoList/TodoList/Item.h | 19 +++ TodoList/TodoList/Item.m | 19 +++ TodoList/TodoList/List.h | 23 ++++ TodoList/TodoList/List.m | 48 +++++++ TodoList/TodoList/Manager.h | 20 +++ TodoList/TodoList/Manager.m | 95 ++++++++++++++ TodoList/TodoList/main.m | 135 +------------------- 8 files changed, 244 insertions(+), 134 deletions(-) create mode 100644 TodoList/TodoList/Item.h create mode 100644 TodoList/TodoList/Item.m create mode 100644 TodoList/TodoList/List.h create mode 100644 TodoList/TodoList/List.m create mode 100644 TodoList/TodoList/Manager.h create mode 100644 TodoList/TodoList/Manager.m diff --git a/TodoList/TodoList.xcodeproj/project.pbxproj b/TodoList/TodoList.xcodeproj/project.pbxproj index 17baea5..61513c8 100644 --- a/TodoList/TodoList.xcodeproj/project.pbxproj +++ b/TodoList/TodoList.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 00824B7A1B4208690025BB5F /* Item.m in Sources */ = {isa = PBXBuildFile; fileRef = 00824B791B4208690025BB5F /* Item.m */; }; + 00824B7C1B42093C0025BB5F /* List.m in Sources */ = {isa = PBXBuildFile; fileRef = 00824B7B1B42093C0025BB5F /* List.m */; }; + 00824B7E1B4209E80025BB5F /* Manager.m in Sources */ = {isa = PBXBuildFile; fileRef = 00824B7D1B4209E80025BB5F /* Manager.m */; }; 8D9789F71B3C9A7F007CF4CF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D9789F61B3C9A7F007CF4CF /* main.m */; }; /* End PBXBuildFile section */ @@ -23,6 +26,12 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 00824B791B4208690025BB5F /* Item.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Item.m; sourceTree = ""; }; + 00824B7B1B42093C0025BB5F /* List.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = List.m; sourceTree = ""; }; + 00824B7D1B4209E80025BB5F /* Manager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Manager.m; sourceTree = ""; }; + 00824B801B420FEC0025BB5F /* Item.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Item.h; sourceTree = ""; }; + 00824B811B4210410025BB5F /* List.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = List.h; sourceTree = ""; }; + 00824B821B42108A0025BB5F /* Manager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Manager.h; sourceTree = ""; }; 8D9789F31B3C9A7F007CF4CF /* TodoList */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TodoList; sourceTree = BUILT_PRODUCTS_DIR; }; 8D9789F61B3C9A7F007CF4CF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -58,6 +67,12 @@ isa = PBXGroup; children = ( 8D9789F61B3C9A7F007CF4CF /* main.m */, + 00824B7D1B4209E80025BB5F /* Manager.m */, + 00824B821B42108A0025BB5F /* Manager.h */, + 00824B791B4208690025BB5F /* Item.m */, + 00824B801B420FEC0025BB5F /* Item.h */, + 00824B811B4210410025BB5F /* List.h */, + 00824B7B1B42093C0025BB5F /* List.m */, ); path = TodoList; sourceTree = ""; @@ -118,7 +133,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 00824B7C1B42093C0025BB5F /* List.m in Sources */, + 00824B7A1B4208690025BB5F /* Item.m in Sources */, 8D9789F71B3C9A7F007CF4CF /* main.m in Sources */, + 00824B7E1B4209E80025BB5F /* Manager.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -235,6 +253,7 @@ 8D9789FC1B3C9A7F007CF4CF /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/TodoList/TodoList/Item.h b/TodoList/TodoList/Item.h new file mode 100644 index 0000000..4ea6854 --- /dev/null +++ b/TodoList/TodoList/Item.h @@ -0,0 +1,19 @@ +// +// Item.h +// TodoList +// +// Created by Felicia Weathers on 6/29/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#ifndef TodoList_Item_h +#define TodoList_Item_h + +@interface Item: NSObject + +@property (nonatomic) NSString *content; + +@end + + +#endif diff --git a/TodoList/TodoList/Item.m b/TodoList/TodoList/Item.m new file mode 100644 index 0000000..5ddc54e --- /dev/null +++ b/TodoList/TodoList/Item.m @@ -0,0 +1,19 @@ +// +// Item.m +// TodoList +// +// Created by Felicia Weathers on 6/29/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "Item.h" + +@implementation Item + +-(NSString *)description +{ + return self.content; +} + +@end \ No newline at end of file diff --git a/TodoList/TodoList/List.h b/TodoList/TodoList/List.h new file mode 100644 index 0000000..fde8516 --- /dev/null +++ b/TodoList/TodoList/List.h @@ -0,0 +1,23 @@ +// +// List.h +// TodoList +// +// Created by Felicia Weathers on 6/29/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#ifndef TodoList_List_h +#define TodoList_List_h + +@interface List: NSObject + +@property (nonatomic) NSMutableArray *items; + +// Calls scanf and creates a new Item and adds that item to items array +-(Item *)scanItem; +-(NSMutableArray *)getItems; + +@end + + +#endif diff --git a/TodoList/TodoList/List.m b/TodoList/TodoList/List.m new file mode 100644 index 0000000..077b92b --- /dev/null +++ b/TodoList/TodoList/List.m @@ -0,0 +1,48 @@ +// +// List.m +// TodoList +// +// Created by Felicia Weathers on 6/29/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "Item.h" +#import "List.h" + +@implementation List + +-(NSString *)description +{ + // What gets printed when the object gets printed + return [NSString stringWithFormat:@"%@", self.items]; +} + +-(Item *)scanItem +{ + if (!self.items) { + self.items = [[NSMutableArray alloc] init]; + } + + printf("What would you like to add to your list?\n"); + + char input[1024]; + scanf("%s", input); + if (strcmp(input, "0") == 0) { + return nil; + } + + Item *item = [[Item alloc] init]; + item.content = @(input); + + [self.items addObject:item]; + + return item; +} + +-(NSMutableArray *)getItems +{ + return self.items; +} + +@end diff --git a/TodoList/TodoList/Manager.h b/TodoList/TodoList/Manager.h new file mode 100644 index 0000000..d8298d0 --- /dev/null +++ b/TodoList/TodoList/Manager.h @@ -0,0 +1,20 @@ +// +// Manager.h +// TodoList +// +// Created by Felicia Weathers on 6/29/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#ifndef TodoList_Manager_h +#define TodoList_Manager_h +@interface Manager: NSObject + +@property (nonatomic) NSMutableArray *lists; + +- (void)start; + +@end + + +#endif diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m new file mode 100644 index 0000000..d439b45 --- /dev/null +++ b/TodoList/TodoList/Manager.m @@ -0,0 +1,95 @@ +// +// Manager.m +// TodoList +// +// Created by Felicia Weathers on 6/29/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "Item.h" +#import "List.h" +#import "Manager.h" + + + + + + +@implementation Manager + +- (List *)createList +{ + if (!self.lists) { + self.lists = [[NSMutableArray alloc] init]; + } + + List *newList = [[List alloc] init]; + [self.lists addObject:newList]; + return newList; +} + + +-(int)showMenu +{ + printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n"); + + int input; + scanf("%d", &input); + + return input; +} + +-(void)printLists +{ + // For each list in self.lists + for (List *list in self.lists) { + printf("%s\n", [[NSString stringWithFormat:@"%@", list] cStringUsingEncoding:NSUTF8StringEncoding]); + } +} + +//-(List *)deleteContent +//{ +// +//} + + +-(void)start +{ + + while (true) { + int menuPicked = [self showMenu]; + + if (menuPicked == 0) { + break; + } + else if (menuPicked == 1){ + List *list = [self createList]; + while (true) { + Item *newItem = [list scanItem]; + if (!newItem) break; + } + } + else if (menuPicked == 2) { + [self printLists]; + } + else if (menuPicked == 3) { + printf("This list contains"); + [self printLists]; + + printf("What would you like to remove?"); + + + int deleteContent; + scanf("%d", &deleteContent); + + if ([[[self.lists firstObject]getItems] count] >= deleteContent) { + [[[self.lists firstObject]getItems]removeObjectAtIndex:deleteContent]; + } + + + } + } +} + +@end diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 311d7f5..367d49f 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -8,143 +8,10 @@ #import -@class Manager; -@class List; -@class Item; +#import "Manager.h" -@interface Manager: NSObject -@property (nonatomic) NSMutableArray *lists; -- (void)start; - -@end - -@interface List: NSObject - -@property (nonatomic) NSMutableArray *items; - -// Calls scanf and creates a new Item and adds that item to items array --(Item *)scanItem; - -@end - -@interface Item: NSObject - -@property (nonatomic) NSString *content; - -@end - - -@implementation Manager - -- (List *)createList -{ - if (!self.lists) { - self.lists = [[NSMutableArray alloc] init]; - } - - List *newList = [[List alloc] init]; - [self.lists addObject:newList]; - return newList; -} - - --(int)showMenu -{ - printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n"); - - int input; - scanf("%d", &input); - - return input; -} - --(void)printLists -{ - // For each list in self.lists - for (List *list in self.lists) { - printf("%s\n", [[NSString stringWithFormat:@"%@", list] cStringUsingEncoding:NSUTF8StringEncoding]); - } -} - -//-(List *)deleteContent -//{ -// -//} - - --(void)start -{ - - while (true) { - int menuPicked = [self showMenu]; - - if (menuPicked == 0) { - break; - } - else if (menuPicked == 1){ - List *list = [self createList]; - while (true) { - Item *newItem = [list scanItem]; - if (!newItem) break; - } - } - else if (menuPicked == 2) { - [self printLists]; - } - else if (menuPicked == 3) { - printf("What would you like to remove?"); - - - int deleteContent; - scanf("%d", &deleteContent); - - } - } -} - -@end - -@implementation List - --(NSString *)description -{ - // What gets printed when the object gets printed - return [NSString stringWithFormat:@"%@", self.items]; -} - --(Item *)scanItem -{ - if (!self.items) { - self.items = [[NSMutableArray alloc] init]; - } - - printf("What would you like to add to your list?\n"); - - char input[1024]; - scanf("%s", input); - if (strcmp(input, "0") == 0) { - return nil; - } - - Item *item = [[Item alloc] init]; - item.content = @(input); - - [self.items addObject:item]; - - return item; -} -@end - -@implementation Item - --(NSString *)description -{ - return self.content; -} - -@end int main(int argc, const char * argv[]) { @autoreleasepool { From 256d4fafe9c1cf1c3a86b47f4abc9bf68808864d Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Mon, 29 Jun 2015 20:44:50 -0400 Subject: [PATCH 09/16] fixed remove and debugged char --- TodoList/TodoList/List.m | 1 + TodoList/TodoList/Manager.m | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TodoList/TodoList/List.m b/TodoList/TodoList/List.m index 077b92b..732e9c8 100644 --- a/TodoList/TodoList/List.m +++ b/TodoList/TodoList/List.m @@ -25,6 +25,7 @@ -(Item *)scanItem } printf("What would you like to add to your list?\n"); + fpurge(stdin); char input[1024]; scanf("%s", input); diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index d439b45..ca8b45c 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -33,6 +33,7 @@ - (List *)createList -(int)showMenu { printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n"); + fpurge(stdin); int input; scanf("%d", &input); @@ -45,6 +46,7 @@ -(void)printLists // For each list in self.lists for (List *list in self.lists) { printf("%s\n", [[NSString stringWithFormat:@"%@", list] cStringUsingEncoding:NSUTF8StringEncoding]); + fpurge(stdin); } } @@ -75,19 +77,21 @@ -(void)start } else if (menuPicked == 3) { printf("This list contains"); + fpurge(stdin); + [self printLists]; printf("What would you like to remove?"); - + fpurge(stdin); + int deleteContent; scanf("%d", &deleteContent); if ([[[self.lists firstObject]getItems] count] >= deleteContent) { - [[[self.lists firstObject]getItems]removeObjectAtIndex:deleteContent]; + [[[self.lists firstObject]getItems]removeObjectAtIndex:deleteContent-1]; + fpurge(stdin); } - - } } } From a5d47d13b126d207ed62e4ce6046772d64529f70 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Mon, 29 Jun 2015 22:00:11 -0400 Subject: [PATCH 10/16] added choices 4&5 --- TodoList/TodoList/List.m | 2 ++ TodoList/TodoList/Manager.m | 44 +++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/TodoList/TodoList/List.m b/TodoList/TodoList/List.m index 732e9c8..083748b 100644 --- a/TodoList/TodoList/List.m +++ b/TodoList/TodoList/List.m @@ -42,6 +42,8 @@ -(Item *)scanItem } -(NSMutableArray *)getItems +//@property (nonatomic) addComplete; + { return self.items; } diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index ca8b45c..2ce005a 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -32,7 +32,7 @@ - (List *)createList -(int)showMenu { - printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n"); + printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n4. Mark as done\n5. Edit Item\n"); fpurge(stdin); int input; @@ -46,16 +46,9 @@ -(void)printLists // For each list in self.lists for (List *list in self.lists) { printf("%s\n", [[NSString stringWithFormat:@"%@", list] cStringUsingEncoding:NSUTF8StringEncoding]); - fpurge(stdin); } } -//-(List *)deleteContent -//{ -// -//} - - -(void)start { @@ -81,7 +74,7 @@ -(void)start [self printLists]; - printf("What would you like to remove?"); + printf("What would you like to remove?\n"); fpurge(stdin); @@ -92,6 +85,39 @@ -(void)start [[[self.lists firstObject]getItems]removeObjectAtIndex:deleteContent-1]; fpurge(stdin); } + else { + printf("Sorry that is not a valid option\n"); + fpurge(stdin); + } + } +/* else if (menuPicked == 4) { + printf("Which item would you like to mark as complete?\n"); + fpurge(stdin); + + [self printLists]; + + int markDone; + scanf("%d", &markDone); + + if ([[self.lists firstObject]getItems] count] >= markDone) { + [[self.lists firstObject]getItems] + } + + }*/ + else if (menuPicked == 5) { + printf("Which item would you like to edit"); + fpurge(stdin); + + [self printLists]; + + int replaceItem; + scanf("%d", &replaceItem); + + if ([[[self.lists firstObject]getItems] count] >= replaceItem) { + Item *newItem = [[self.lists firstObject]scanItem]; + + [[[self.lists firstObject]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; + } } } } From f0ac9a1ee0f3c2e1e54479187cc050a3d849b5ed Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Tue, 30 Jun 2015 12:56:25 -0400 Subject: [PATCH 11/16] fixed edit bug, now to fix array of lists --- TodoList/TodoList/Manager.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index 2ce005a..f365cdf 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -114,9 +114,11 @@ -(void)start scanf("%d", &replaceItem); if ([[[self.lists firstObject]getItems] count] >= replaceItem) { - Item *newItem = [[self.lists firstObject]scanItem]; + Item *newItem = [ [self.lists firstObject]scanItem]; [[[self.lists firstObject]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; + [[[self.lists firstObject]getItems] removeLastObject]; + } } } From e684e669ae700b9bad5a657f2bf2cb4319e92f8d Mon Sep 17 00:00:00 2001 From: Eric Sze Date: Wed, 1 Jul 2015 19:34:17 -0400 Subject: [PATCH 12/16] fixed string --- TodoList/TodoList.xcodeproj/project.pbxproj | 4 ++-- TodoList/TodoList/List.m | 17 +++++++++-------- TodoList/TodoList/Manager.m | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/TodoList/TodoList.xcodeproj/project.pbxproj b/TodoList/TodoList.xcodeproj/project.pbxproj index 61513c8..8a9a73b 100644 --- a/TodoList/TodoList.xcodeproj/project.pbxproj +++ b/TodoList/TodoList.xcodeproj/project.pbxproj @@ -67,10 +67,10 @@ isa = PBXGroup; children = ( 8D9789F61B3C9A7F007CF4CF /* main.m */, - 00824B7D1B4209E80025BB5F /* Manager.m */, 00824B821B42108A0025BB5F /* Manager.h */, - 00824B791B4208690025BB5F /* Item.m */, + 00824B7D1B4209E80025BB5F /* Manager.m */, 00824B801B420FEC0025BB5F /* Item.h */, + 00824B791B4208690025BB5F /* Item.m */, 00824B811B4210410025BB5F /* List.h */, 00824B7B1B42093C0025BB5F /* List.m */, ); diff --git a/TodoList/TodoList/List.m b/TodoList/TodoList/List.m index 083748b..a92d114 100644 --- a/TodoList/TodoList/List.m +++ b/TodoList/TodoList/List.m @@ -17,21 +17,22 @@ -(NSString *)description // What gets printed when the object gets printed return [NSString stringWithFormat:@"%@", self.items]; } - -(Item *)scanItem { if (!self.items) { self.items = [[NSMutableArray alloc] init]; } - printf("What would you like to add to your list?\n"); - fpurge(stdin); + printf("What would you like to add to your list? (Or enter 0 to exit) \n"); - char input[1024]; - scanf("%s", input); - if (strcmp(input, "0") == 0) { - return nil; - } + + NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; + NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + +// if (strcmp(input, "0") == 0) { +// return nil; +// } Item *item = [[Item alloc] init]; item.content = @(input); diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index f365cdf..67d6f90 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -69,7 +69,7 @@ -(void)start [self printLists]; } else if (menuPicked == 3) { - printf("This list contains"); + printf("This list contains:\n"); fpurge(stdin); [self printLists]; @@ -105,7 +105,7 @@ -(void)start }*/ else if (menuPicked == 5) { - printf("Which item would you like to edit"); + printf("Which item would you like to edit?\n"); fpurge(stdin); [self printLists]; From 77c75fc4c0718fec336e7c20e8ea092e70564e51 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Wed, 1 Jul 2015 20:31:41 -0400 Subject: [PATCH 13/16] we did it --- TodoList/TodoList/List.m | 10 ++++++---- TodoList/TodoList/Manager.m | 26 +++++++++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/TodoList/TodoList/List.m b/TodoList/TodoList/List.m index a92d114..f81b271 100644 --- a/TodoList/TodoList/List.m +++ b/TodoList/TodoList/List.m @@ -29,13 +29,15 @@ -(Item *)scanItem NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + const char *command = [inputLine UTF8String]; -// if (strcmp(input, "0") == 0) { -// return nil; -// } + if (command[0] == '0') { + + return nil; + } Item *item = [[Item alloc] init]; - item.content = @(input); + item.content = (inputLine); [self.items addObject:item]; diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index 67d6f90..730f50f 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -32,7 +32,7 @@ - (List *)createList -(int)showMenu { - printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n4. Mark as done\n5. Edit Item\n"); + printf("What would you like to do?\n0. Exit\n1. Create a list\n2. Print lists\n3. Remove content\n4. Edit Item\n"); fpurge(stdin); int input; @@ -69,6 +69,12 @@ -(void)start [self printLists]; } else if (menuPicked == 3) { + printf("Which list would you like to access?\n"); + fpurge(stdin); + + int accessArray; + scanf("%d", &accessArray); + printf("This list contains:\n"); fpurge(stdin); @@ -81,8 +87,8 @@ -(void)start int deleteContent; scanf("%d", &deleteContent); - if ([[[self.lists firstObject]getItems] count] >= deleteContent) { - [[[self.lists firstObject]getItems]removeObjectAtIndex:deleteContent-1]; + if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] >= deleteContent) { + [[[self.lists objectAtIndex:accessArray-1]getItems]removeObjectAtIndex:deleteContent-1]; fpurge(stdin); } else { @@ -104,7 +110,13 @@ -(void)start } }*/ - else if (menuPicked == 5) { + else if (menuPicked == 4) { + printf("Which list would you like to access?\n"); + fpurge(stdin); + + int accessArrayAlso; + scanf("%d", &accessArrayAlso); + printf("Which item would you like to edit?\n"); fpurge(stdin); @@ -113,11 +125,11 @@ -(void)start int replaceItem; scanf("%d", &replaceItem); - if ([[[self.lists firstObject]getItems] count] >= replaceItem) { + if ([[[self.lists objectAtIndex:accessArrayAlso-1]getItems] count] >= replaceItem) { Item *newItem = [ [self.lists firstObject]scanItem]; - [[[self.lists firstObject]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; - [[[self.lists firstObject]getItems] removeLastObject]; + [[[self.lists objectAtIndex:accessArrayAlso-1]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; + [[[self.lists objectAtIndex:accessArrayAlso-1]getItems] removeLastObject]; } } From 20986ece0371eb15d477debebb90cd60650523a8 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Wed, 1 Jul 2015 20:58:09 -0400 Subject: [PATCH 14/16] error --- TodoList/TodoList/Manager.m | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index 730f50f..01bee7a 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -87,7 +87,7 @@ -(void)start int deleteContent; scanf("%d", &deleteContent); - if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] >= deleteContent) { + if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] > deleteContent) { [[[self.lists objectAtIndex:accessArray-1]getItems]removeObjectAtIndex:deleteContent-1]; fpurge(stdin); } @@ -111,11 +111,15 @@ -(void)start }*/ else if (menuPicked == 4) { + NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; + NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + printf("Which list would you like to access?\n"); fpurge(stdin); - int accessArrayAlso; - scanf("%d", &accessArrayAlso); + int accessArray; + scanf("%d", &accessArray); printf("Which item would you like to edit?\n"); fpurge(stdin); @@ -125,13 +129,18 @@ -(void)start int replaceItem; scanf("%d", &replaceItem); - if ([[[self.lists objectAtIndex:accessArrayAlso-1]getItems] count] >= replaceItem) { - Item *newItem = [ [self.lists firstObject]scanItem]; + if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] > replaceItem) { + Item *newItem = [ [self.lists objectAtIndex:accessArray-1]scanItem]; - [[[self.lists objectAtIndex:accessArrayAlso-1]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; - [[[self.lists objectAtIndex:accessArrayAlso-1]getItems] removeLastObject]; + [[[self.lists objectAtIndex:accessArray-1]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; + [[[self.lists objectAtIndex:accessArray-1]getItems] removeLastObject]; } + else if (command[0] == '0'){ + + printf("Not a valid option"); + fpurge(stdin); + } } } } From 3adcd932c6f5b3129890a32a4e72744568896e40 Mon Sep 17 00:00:00 2001 From: Felicia Weathers Date: Wed, 1 Jul 2015 21:46:22 -0400 Subject: [PATCH 15/16] debugged --- TodoList/TodoList/Manager.m | 54 +++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index 01bee7a..96c0caa 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -77,12 +77,12 @@ -(void)start printf("This list contains:\n"); fpurge(stdin); - + [self printLists]; printf("What would you like to remove?\n"); fpurge(stdin); - + int deleteContent; scanf("%d", &deleteContent); @@ -96,25 +96,21 @@ -(void)start fpurge(stdin); } } -/* else if (menuPicked == 4) { - printf("Which item would you like to mark as complete?\n"); - fpurge(stdin); - - [self printLists]; - - int markDone; - scanf("%d", &markDone); - - if ([[self.lists firstObject]getItems] count] >= markDone) { - [[self.lists firstObject]getItems] - } - - }*/ + /* else if (menuPicked == 4) { + printf("Which item would you like to mark as complete?\n"); + fpurge(stdin); + + [self printLists]; + + int markDone; + scanf("%d", &markDone); + + if ([[self.lists firstObject]getItems] count] >= markDone) { + [[self.lists firstObject]getItems] + } + + }*/ else if (menuPicked == 4) { - NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; - NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - - printf("Which list would you like to access?\n"); fpurge(stdin); @@ -130,19 +126,17 @@ -(void)start scanf("%d", &replaceItem); if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] > replaceItem) { + Item *newItem = [ [self.lists objectAtIndex:accessArray-1]scanItem]; - - [[[self.lists objectAtIndex:accessArray-1]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; - [[[self.lists objectAtIndex:accessArray-1]getItems] removeLastObject]; - - } - else if (command[0] == '0'){ - - printf("Not a valid option"); - fpurge(stdin); + + if (newItem != nil) { + + [[[self.lists objectAtIndex:accessArray-1]getItems] replaceObjectAtIndex:replaceItem-1 withObject:newItem]; + + [[[self.lists objectAtIndex:accessArray-1]getItems] removeLastObject]; + } } } } } - @end From 6b64129d5808425d759c2ad3b5a58441113e7a38 Mon Sep 17 00:00:00 2001 From: Eric Sze Date: Wed, 1 Jul 2015 21:54:04 -0400 Subject: [PATCH 16/16] newest changes >= --- TodoList/TodoList/Manager.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TodoList/TodoList/Manager.m b/TodoList/TodoList/Manager.m index 96c0caa..17dc6a1 100644 --- a/TodoList/TodoList/Manager.m +++ b/TodoList/TodoList/Manager.m @@ -87,7 +87,7 @@ -(void)start int deleteContent; scanf("%d", &deleteContent); - if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] > deleteContent) { + if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] >= deleteContent) { [[[self.lists objectAtIndex:accessArray-1]getItems]removeObjectAtIndex:deleteContent-1]; fpurge(stdin); } @@ -125,7 +125,7 @@ -(void)start int replaceItem; scanf("%d", &replaceItem); - if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] > replaceItem) { + if ([[[self.lists objectAtIndex:accessArray-1]getItems] count] >= replaceItem) { Item *newItem = [ [self.lists objectAtIndex:accessArray-1]scanItem];