From 7faf8dd0c7b2e3171eea724491836f90e6f960d6 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Sat, 27 Jun 2015 12:05:05 -0400 Subject: [PATCH 01/19] added our names to the title --- TodoList/TodoList/main.m | 1 + 1 file changed, 1 insertion(+) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 187be40..302ada9 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -3,6 +3,7 @@ // TodoList // // Created by Michael Kavouras on 6/25/15. +// Homework by Xiulan and Shena 6/27/15. // Copyright (c) 2015 Mike Kavouras. All rights reserved. // From fa95ff7ce98d31f822b86959819a3934c0348e62 Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Sat, 27 Jun 2015 15:49:27 -0400 Subject: [PATCH 02/19] We added Item Class --- TodoList/TodoList/main.m | 78 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 302ada9..c74fba9 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -9,10 +9,84 @@ #import +// create class declarations +@class ToDoApp; +@class ToDoList; +@class ToDoItem; + +//ToDoApp class (we declare methods here) +@interface ToDoApp : NSObject +@end + +@implementation ToDoApp +@end + +//ToDoList class +@interface ToDoList : NSObject +//- (void)setListTitle:(NSString *)title; +//- (NSString *)title; +//- (void)setList: +@end + +@implementation ToDoList +@end + +//ToDoItem class +@interface ToDoItem : NSObject +- (void)setItem:(NSString *)item; +- (NSString *)item; +- (void)addNameAndPriority; +@end + +@implementation ToDoItem { + NSString *_item; + int _priority; +} + +- (void)setItem:(NSString *)item { + _item = item; +} +- (NSString *)item { + return _item; +} + + +- (void)addNameAndPriority { + NSLog(@"Enter your To Do List item: "); + char itemName[256]; + scanf("%s", itemName); + + + NSLog(@"added: %s", itemName); + + NSString *item1 = [NSString stringWithUTF8String:itemName]; + NSLog(@"string test: %@", item1); + + _item = item1; + + NSLog(@"Enter priority 1, 2, 3: "); + int inputPriority; + scanf("%d", &inputPriority); + _priority = inputPriority; + + + NSLog(@"%@, %d",_item, _priority); + +} + +@end + + + + + + int main(int argc, const char * argv[]) { @autoreleasepool { - // insert code here... - NSLog(@"Hello, World!"); + + ToDoItem *addItem = [[ToDoItem alloc]init]; + [addItem addNameAndPriority]; + } return 0; } From 10cdd03cb50b74a186fb475f5ddd7b385438cfb9 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Sat, 27 Jun 2015 16:10:23 -0400 Subject: [PATCH 03/19] added more stuff --- TodoList/TodoList/main.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index c74fba9..0316c62 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -50,9 +50,15 @@ - (NSString *)item { return _item; } +- (void)setPriority: (int) priority { + _priority = priority; +} +- (int) priority { + return _priority; +} - (void)addNameAndPriority { - NSLog(@"Enter your To Do List item: "); + NSLog(@"Enter item: "); char itemName[256]; scanf("%s", itemName); @@ -62,15 +68,15 @@ - (void)addNameAndPriority { NSString *item1 = [NSString stringWithUTF8String:itemName]; NSLog(@"string test: %@", item1); - _item = item1; + [self setItem: item1]; NSLog(@"Enter priority 1, 2, 3: "); int inputPriority; scanf("%d", &inputPriority); - _priority = inputPriority; + [self setPriority: inputPriority]; - NSLog(@"%@, %d",_item, _priority); + NSLog(@"%@, %d",item1, inputPriority); } From 535ee6625f2a85ad596498a3a66b7a40ee413be5 Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Sat, 27 Jun 2015 17:33:16 -0400 Subject: [PATCH 04/19] Trying to work on the List class, not working yet --- TodoList/TodoList/main.m | 99 +++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 32 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 0316c62..ac4b9ed 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -9,45 +9,28 @@ #import -// create class declarations -@class ToDoApp; -@class ToDoList; -@class ToDoItem; - -//ToDoApp class (we declare methods here) -@interface ToDoApp : NSObject -@end - -@implementation ToDoApp -@end - -//ToDoList class -@interface ToDoList : NSObject -//- (void)setListTitle:(NSString *)title; -//- (NSString *)title; -//- (void)setList: -@end - -@implementation ToDoList -@end +//// create class declarations +//@class ToDoApp; +//@class ToDoList; +//@class ToDoItem; //ToDoItem class @interface ToDoItem : NSObject -- (void)setItem:(NSString *)item; -- (NSString *)item; +- (void)setItem:(NSString *)itemName; +- (NSString *)itemName; - (void)addNameAndPriority; @end @implementation ToDoItem { - NSString *_item; + NSString *_itemName; int _priority; } -- (void)setItem:(NSString *)item { - _item = item; +- (void)setItem:(NSString *)itemName { + _itemName = itemName; } -- (NSString *)item { - return _item; +- (NSString *)itemName { + return _itemName; } - (void)setPriority: (int) priority { @@ -59,13 +42,13 @@ - (int) priority { - (void)addNameAndPriority { NSLog(@"Enter item: "); - char itemName[256]; - scanf("%s", itemName); + char name[256]; + scanf("%s", name); - NSLog(@"added: %s", itemName); + NSLog(@"added: %s", name); - NSString *item1 = [NSString stringWithUTF8String:itemName]; + NSString *item1 = [NSString stringWithUTF8String:name]; NSLog(@"string test: %@", item1); [self setItem: item1]; @@ -77,8 +60,51 @@ - (void)addNameAndPriority { [self setPriority: inputPriority]; NSLog(@"%@, %d",item1, inputPriority); + +} + +@end + + + +//ToDoApp class (we declare methods here) +@interface ToDoApp : NSObject +@end + +@implementation ToDoApp +@end +//ToDoList class +@interface ToDoList : NSObject +//- (void)setListTitle:(NSString *)title; +//- (NSString *)title; +//- (void)setList: +-(void)addItem:(ToDoItem *)newItem; +-(void)printList; + +@end + +@implementation ToDoList { + NSMutableArray *_myListedItems; } +// 6/27 note: we're not sure if this is adding items as we can't print out items. double check this! +-(void)addItem:(ToDoItem *)newItem { + [_myListedItems addObject:newItem]; + +} + +-(void)printList { + NSLog(@"%lu", (unsigned long)[_myListedItems count]); + for (int i = 0; i < [_myListedItems count]; i++) { + NSLog(@"itemName:%@", [[_myListedItems objectAtIndex:i] itemName]); + } + +} + +//-(void)setList:(NSMutableArray *)list { +// _myListedItems = list; +//} + @end @@ -87,12 +113,21 @@ - (void)addNameAndPriority { + int main(int argc, const char * argv[]) { @autoreleasepool { ToDoItem *addItem = [[ToDoItem alloc]init]; [addItem addNameAndPriority]; + + ToDoList *addList = [[ToDoList alloc] init]; + [addList addItem:addItem]; + + [addList printList]; + + + } return 0; } From 71ed681dc969255acf8cc2c6d0e0fd3e65a83612 Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Sun, 28 Jun 2015 12:51:51 -0400 Subject: [PATCH 05/19] Updated the list class --- TodoList/TodoList/main.m | 89 ++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 27 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index ac4b9ed..a387af2 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -8,17 +8,17 @@ // #import +// create class declarations +@class ToDoApp; +@class ToDoList; +@class ToDoItem; -//// create class declarations -//@class ToDoApp; -//@class ToDoList; -//@class ToDoItem; - -//ToDoItem class +// *** ToDoItem class *** *** *** *** *** *** *** *** *** *** *** *** *** *** @interface ToDoItem : NSObject - (void)setItem:(NSString *)itemName; - (NSString *)itemName; - (void)addNameAndPriority; +//- (BOOL)noMoreItems; @end @implementation ToDoItem { @@ -40,63 +40,90 @@ - (int) priority { return _priority; } + - (void)addNameAndPriority { NSLog(@"Enter item: "); + // "fgets" allows the user to input an item with more than one word ie: "cat food" char name[256]; - scanf("%s", name); + fgets(name, 256, stdin); + NSLog(@"item added: %s", name); // we test our work above here - NSLog(@"added: %s", name); - + // we used "stringWithUTF8String" to convert char to string NSString *item1 = [NSString stringWithUTF8String:name]; - NSLog(@"string test: %@", item1); +// NSLog(@"string test: %@", item1); [self setItem: item1]; + // we set the priority level for each inputted item NSLog(@"Enter priority 1, 2, 3: "); int inputPriority; scanf("%d", &inputPriority); [self setPriority: inputPriority]; - NSLog(@"%@, %d",item1, inputPriority); + // we print/test the inputted item name and priority + NSLog(@"priority level: %d", inputPriority); } +// we set up a BOOL, so that the program knows when to stop or continue adding To Do List items: +//-(BOOL)noMoreItems { +// NSLog(@"1 = add another item, 0 = stop adding items, my list is complete"); +// int answer; +// scanf("%d", &answer); +// fpurge(stdin); +// +// return answer != 0; +//} @end -//ToDoApp class (we declare methods here) -@interface ToDoApp : NSObject -@end +// *** ToDoList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** +@interface ToDoList : NSObject -@implementation ToDoApp -@end +//@property (nonatomic) NSMutableArray *myListedItems; -//ToDoList class -@interface ToDoList : NSObject -//- (void)setListTitle:(NSString *)title; -//- (NSString *)title; -//- (void)setList: + +-(NSMutableArray *)myListedItems; -(void)addItem:(ToDoItem *)newItem; -(void)printList; - @end @implementation ToDoList { NSMutableArray *_myListedItems; } -// 6/27 note: we're not sure if this is adding items as we can't print out items. double check this! + + //initialize our list of items: +-(NSMutableArray *)myListedItems { + if (_myListedItems == nil) { + _myListedItems = [[NSMutableArray alloc] init]; + } + return _myListedItems; +} + +// this initializes our list of items (same as above, but better!) +//- (instancetype)init +//{ +// if ((self = [super init])) { +// // create myListedItems +// _myListedItems = [[NSMutableArray alloc] init]; +// } +// return self; +//} + + -(void)addItem:(ToDoItem *)newItem { - [_myListedItems addObject:newItem]; - + [[self myListedItems] addObject:newItem]; } + + -(void)printList { - NSLog(@"%lu", (unsigned long)[_myListedItems count]); +// NSLog(@"%lu", (unsigned long)[_myListedItems count]); for (int i = 0; i < [_myListedItems count]; i++) { - NSLog(@"itemName:%@", [[_myListedItems objectAtIndex:i] itemName]); + NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); } } @@ -108,6 +135,14 @@ -(void)printList { @end +// *** ToDoApp class *** *** *** *** *** *** *** *** *** *** *** *** *** *** + +@interface ToDoApp : NSObject +@end + +@implementation ToDoApp +@end + From 6b54435d6b54768cc0b324a561341d9ecb5ea7e2 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Sun, 28 Jun 2015 15:04:47 -0400 Subject: [PATCH 06/19] added a loop --- TodoList/TodoList/main.m | 89 ++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index a387af2..b27a9ed 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -9,7 +9,7 @@ #import // create class declarations -@class ToDoApp; +@class ManageList; @class ToDoList; @class ToDoItem; @@ -42,29 +42,45 @@ - (int) priority { - (void)addNameAndPriority { - NSLog(@"Enter item: "); - // "fgets" allows the user to input an item with more than one word ie: "cat food" - char name[256]; - fgets(name, 256, stdin); - - NSLog(@"item added: %s", name); // we test our work above here - - // we used "stringWithUTF8String" to convert char to string - NSString *item1 = [NSString stringWithUTF8String:name]; -// NSLog(@"string test: %@", item1); - - [self setItem: item1]; - - // we set the priority level for each inputted item - NSLog(@"Enter priority 1, 2, 3: "); - int inputPriority; - scanf("%d", &inputPriority); - - [self setPriority: inputPriority]; - - // we print/test the inputted item name and priority - NSLog(@"priority level: %d", inputPriority); + int addOrQuit; + while (true) { + NSLog(@"Enter 1 to add an item or 0 to quit"); + scanf("%d", &addOrQuit); + fpurge(stdin); + + if (addOrQuit == 1) { + + NSLog(@"Enter item: "); + // "fgets" allows the user to input an item with more than one word ie: "cat food" + char name[256]; + fgets(name, 256, stdin); + + NSLog(@"item added: %s", name); // we test our work above here + + + + // we used "stringWithUTF8String" to convert char to string + NSString *item1 = [NSString stringWithUTF8String:name]; + // NSLog(@"string test: %@", item1); + + [self setItem: item1]; + + + // we set the priority level for each inputted item + NSLog(@"Enter priority 1 = hair on fire urgent, 2, 3, 4 = whatever, later: "); + int inputPriority; + scanf("%d", &inputPriority); + + [self setPriority: inputPriority]; + + // we print/test the inputted item name and priority + NSLog(@"priority level: %d", inputPriority); + } else { + NSLog(@"you quit"); + break; + } + } } // we set up a BOOL, so that the program knows when to stop or continue adding To Do List items: //-(BOOL)noMoreItems { @@ -72,7 +88,7 @@ - (void)addNameAndPriority { // int answer; // scanf("%d", &answer); // fpurge(stdin); -// +// // return answer != 0; //} @@ -95,7 +111,7 @@ @implementation ToDoList { NSMutableArray *_myListedItems; } - //initialize our list of items: +//initialize our list of items: -(NSMutableArray *)myListedItems { if (_myListedItems == nil) { _myListedItems = [[NSMutableArray alloc] init]; @@ -119,43 +135,38 @@ -(void)addItem:(ToDoItem *)newItem { } - -(void)printList { -// NSLog(@"%lu", (unsigned long)[_myListedItems count]); + // NSLog(@"%lu", (unsigned long)[_myListedItems count]); for (int i = 0; i < [_myListedItems count]; i++) { NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); } - + } //-(void)setList:(NSMutableArray *)list { // _myListedItems = list; //} - @end -// *** ToDoApp class *** *** *** *** *** *** *** *** *** *** *** *** *** *** +// *** ManageList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** -@interface ToDoApp : NSObject +@interface ManageList : NSObject @end -@implementation ToDoApp +@implementation ManageList @end - - - - - - +// *** MAIN *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** int main(int argc, const char * argv[]) { @autoreleasepool { + + ToDoItem *addItem = [[ToDoItem alloc]init]; [addItem addNameAndPriority]; - + ToDoList *addList = [[ToDoList alloc] init]; [addList addItem:addItem]; From 2fa338c2fda8f239b74935a5fc8fbeee4567f22c Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Sun, 28 Jun 2015 15:53:09 -0400 Subject: [PATCH 07/19] added content to other classes --- TodoList/TodoList/main.m | 102 ++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index b27a9ed..f4107d3 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -43,44 +43,31 @@ - (int) priority { - (void)addNameAndPriority { - int addOrQuit; - while (true) { - NSLog(@"Enter 1 to add an item or 0 to quit"); - scanf("%d", &addOrQuit); - fpurge(stdin); - - if (addOrQuit == 1) { - - NSLog(@"Enter item: "); - // "fgets" allows the user to input an item with more than one word ie: "cat food" - char name[256]; - fgets(name, 256, stdin); - - NSLog(@"item added: %s", name); // we test our work above here - - - - // we used "stringWithUTF8String" to convert char to string - NSString *item1 = [NSString stringWithUTF8String:name]; - // NSLog(@"string test: %@", item1); - - [self setItem: item1]; - - - // we set the priority level for each inputted item - NSLog(@"Enter priority 1 = hair on fire urgent, 2, 3, 4 = whatever, later: "); - int inputPriority; - scanf("%d", &inputPriority); - - [self setPriority: inputPriority]; - - // we print/test the inputted item name and priority - NSLog(@"priority level: %d", inputPriority); - } else { - NSLog(@"you quit"); - break; - } - } + NSLog(@"Enter item: "); + // "fgets" allows the user to input an item with more than one word ie: "cat food" + char name[256]; + fgets(name, 256, stdin); + + NSLog(@"item added: %s", name); // we test our work above here + + + + // we used "stringWithUTF8String" to convert char to string + NSString *item1 = [NSString stringWithUTF8String:name]; + // NSLog(@"string test: %@", item1); + + [self setItem: item1]; + + + // we set the priority level for each inputted item + NSLog(@"Enter priority 1 = hair on fire urgent, 2, 3, 4 = whatever, later: "); + int inputPriority; + scanf("%d", &inputPriority); + + [self setPriority: inputPriority]; + + // we print/test the inputted item name and priority + NSLog(@"priority level: %d", inputPriority); } // we set up a BOOL, so that the program knows when to stop or continue adding To Do List items: //-(BOOL)noMoreItems { @@ -139,6 +126,8 @@ -(void)printList { // NSLog(@"%lu", (unsigned long)[_myListedItems count]); for (int i = 0; i < [_myListedItems count]; i++) { NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); + +// NSLog(@"print array: %@", [_myListedItems ob]); } } @@ -147,6 +136,30 @@ -(void)printList { // _myListedItems = list; //} +- (void)createItems { + + int add; + while (true) { + NSLog(@"Enter 1 to add an item or 0 to quit"); + scanf("%d", &add); + fpurge(stdin); + + if (add == 1) { + + // created a new Item object and set its item/priority + ToDoItem *newItem = [[ToDoItem alloc] init]; + [newItem addNameAndPriority]; + + + // added the Item to `self`'s myListedItems array + [self addItem:newItem]; + } else { + NSLog(@"you quit"); + break; + } + } +} + @end // *** ManageList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** @@ -160,20 +173,9 @@ @implementation ManageList // *** MAIN *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** int main(int argc, const char * argv[]) { @autoreleasepool { - - - - ToDoItem *addItem = [[ToDoItem alloc]init]; - [addItem addNameAndPriority]; - - ToDoList *addList = [[ToDoList alloc] init]; - [addList addItem:addItem]; - + [addList createItems]; [addList printList]; - - - } return 0; } From 5551136083108729177526a781dd4186d5d654fd Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Sun, 28 Jun 2015 16:22:57 -0400 Subject: [PATCH 08/19] clean up old comments --- TodoList/TodoList/main.m | 73 +++++++++++----------------------------- 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index f4107d3..199c952 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -18,7 +18,6 @@ @interface ToDoItem : NSObject - (void)setItem:(NSString *)itemName; - (NSString *)itemName; - (void)addNameAndPriority; -//- (BOOL)noMoreItems; @end @implementation ToDoItem { @@ -40,7 +39,6 @@ - (int) priority { return _priority; } - - (void)addNameAndPriority { NSLog(@"Enter item: "); @@ -49,46 +47,24 @@ - (void)addNameAndPriority { fgets(name, 256, stdin); NSLog(@"item added: %s", name); // we test our work above here - - - // we used "stringWithUTF8String" to convert char to string NSString *item1 = [NSString stringWithUTF8String:name]; // NSLog(@"string test: %@", item1); - [self setItem: item1]; - - // we set the priority level for each inputted item NSLog(@"Enter priority 1 = hair on fire urgent, 2, 3, 4 = whatever, later: "); int inputPriority; scanf("%d", &inputPriority); [self setPriority: inputPriority]; - // we print/test the inputted item name and priority NSLog(@"priority level: %d", inputPriority); } -// we set up a BOOL, so that the program knows when to stop or continue adding To Do List items: -//-(BOOL)noMoreItems { -// NSLog(@"1 = add another item, 0 = stop adding items, my list is complete"); -// int answer; -// scanf("%d", &answer); -// fpurge(stdin); -// -// return answer != 0; -//} - @end - - // *** ToDoList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** @interface ToDoList : NSObject -//@property (nonatomic) NSMutableArray *myListedItems; - - -(NSMutableArray *)myListedItems; -(void)addItem:(ToDoItem *)newItem; -(void)printList; @@ -106,51 +82,31 @@ -(NSMutableArray *)myListedItems { return _myListedItems; } -// this initializes our list of items (same as above, but better!) -//- (instancetype)init -//{ -// if ((self = [super init])) { -// // create myListedItems -// _myListedItems = [[NSMutableArray alloc] init]; -// } -// return self; -//} - - -(void)addItem:(ToDoItem *)newItem { [[self myListedItems] addObject:newItem]; } - -(void)printList { - // NSLog(@"%lu", (unsigned long)[_myListedItems count]); for (int i = 0; i < [_myListedItems count]; i++) { NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); - -// NSLog(@"print array: %@", [_myListedItems ob]); } - } -//-(void)setList:(NSMutableArray *)list { -// _myListedItems = list; -//} - - (void)createItems { - int add; + // we started our while loop to add multiple items to the list while (true) { - NSLog(@"Enter 1 to add an item or 0 to quit"); + NSLog(@"Enter 1 to add an item or 0 to quit:"); scanf("%d", &add); + // "fpurge" stopped our code from displaying all at once fpurge(stdin); - + // added "if" condition to allow the user to stop or continue adding items to list if (add == 1) { - - // created a new Item object and set its item/priority + // created a new Item object and set its item/priority. This addes our item to the memory ToDoItem *newItem = [[ToDoItem alloc] init]; + // this sends a message to add an item [newItem addNameAndPriority]; - - + // added the Item to `self`'s myListedItems array [self addItem:newItem]; } else { @@ -159,15 +115,26 @@ - (void)createItems { } } } - @end // *** ManageList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** @interface ManageList : NSObject +//-(NSMutableArray *)manageMyList; +//-(void)manageAddList:(ToDoList *)newList; +//-(void)managePrintList; +// @end -@implementation ManageList +@implementation ManageList { +// NSMutableArray *_manageMyList; +//} +// +//// +//-(NSMutableArray *)manageMyList; +//-(void)manageAddList:(ToDoList *)newList; +//-(void)managePrintList; +} @end // *** MAIN *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** From 6c9796dcacb91a0f28396c3f4acd924273af86ef Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Sun, 28 Jun 2015 16:55:28 -0400 Subject: [PATCH 09/19] added manage list class --- TodoList/TodoList/main.m | 77 ++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 199c952..b6af7ff 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -68,10 +68,13 @@ @interface ToDoList : NSObject -(NSMutableArray *)myListedItems; -(void)addItem:(ToDoItem *)newItem; -(void)printList; +-(void)setListName:(NSString *)listName; +-(NSString *)listName; @end @implementation ToDoList { NSMutableArray *_myListedItems; + NSString *_listName; } //initialize our list of items: @@ -115,34 +118,78 @@ - (void)createItems { } } } +-(void)setListName:(NSString *)listName { + _listName = listName; +} +-(NSString *)listName { + return _listName; +} @end // *** ManageList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** @interface ManageList : NSObject -//-(NSMutableArray *)manageMyList; -//-(void)manageAddList:(ToDoList *)newList; -//-(void)managePrintList; -// +-(NSMutableArray *)manageMyList; +-(void)manageAddList:(ToDoList *)newList; +-(void)managePrintList; + @end @implementation ManageList { -// NSMutableArray *_manageMyList; -//} -// -//// -//-(NSMutableArray *)manageMyList; -//-(void)manageAddList:(ToDoList *)newList; -//-(void)managePrintList; + NSMutableArray *_manageMyList; +} + +//initialize manageMylist +-(NSMutableArray *)manageMyList { + if (_manageMyList == nil) { + _manageMyList = [[NSMutableArray alloc] init]; + } + return _manageMyList; +} + +-(void)manageAddList:(ToDoList *)newList { + [[self manageMyList] addObject:newList]; +} + +-(void)managePrintList { + for (int i = 0; i < [_manageMyList count]; i++) { + NSLog(@"Print master list: %@", [[_manageMyList objectAtIndex:i] listName]); + } +} + +-(void)manageNewList { + int addList; + while (true) { + NSLog(@"Enter 1 to create a new list or 0 to quit:"); + scanf("%d", &addList); + fpurge(stdin); + //later we can add more functionality ie edit a list or delete a list + if (addList == 1) { + ToDoList *newList = [[ToDoList alloc] init]; + [newList createItems]; + + [self manageAddList:newList]; + } else { + NSLog(@"Good bye!"); + break; + } + } } @end // *** MAIN *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** int main(int argc, const char * argv[]) { @autoreleasepool { - ToDoList *addList = [[ToDoList alloc] init]; - [addList createItems]; - [addList printList]; - } + + ManageList *newList = [[ManageList alloc] init]; + + [newList manageNewList]; + [newList managePrintList]; +// ToDoList *addList = [[ToDoList alloc] init]; +// [addList createItems]; +// [addList printList]; + + + } return 0; } From 7b7b830f40f7e101ca6ca8c66363f222f77f45e8 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Sun, 28 Jun 2015 18:09:21 -0400 Subject: [PATCH 10/19] end of day updates --- TodoList/TodoList/main.m | 49 ++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index b6af7ff..42059f1 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -8,12 +8,15 @@ // #import -// create class declarations -@class ManageList; -@class ToDoList; + +// *** CLASS DECLERATIONS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** + @class ToDoItem; +@class ToDoList; +@class ManageList; + +// *** TO DO ITEM CLASS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** -// *** ToDoItem class *** *** *** *** *** *** *** *** *** *** *** *** *** *** @interface ToDoItem : NSObject - (void)setItem:(NSString *)itemName; - (NSString *)itemName; @@ -62,7 +65,8 @@ - (void)addNameAndPriority { } @end -// *** ToDoList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** +// *** TO DO LIST CLASS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** *** *** *** + @interface ToDoList : NSObject -(NSMutableArray *)myListedItems; @@ -113,7 +117,7 @@ - (void)createItems { // added the Item to `self`'s myListedItems array [self addItem:newItem]; } else { - NSLog(@"you quit"); +// NSLog(@"Finished adding items"); break; } } @@ -124,14 +128,27 @@ -(void)setListName:(NSString *)listName { -(NSString *)listName { return _listName; } +-(void)addListTitle { +// NSLog(@"Enter 1 to create a new list or 0 to quit:"); + NSLog(@"Please name your list:"); + char name[256]; + fgets(name, 256, stdin); +// NSLog(@"%s: list name", name); + NSString *item2 = [NSString stringWithUTF8String:name]; + [self setListName: item2]; + NSLog(@"Now, let's add items to %s list!", name); + +} + @end -// *** ManageList class *** *** *** *** *** *** *** *** *** *** *** *** *** *** +// *** MANAGE LIST CLASS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** *** *** *** @interface ManageList : NSObject -(NSMutableArray *)manageMyList; -(void)manageAddList:(ToDoList *)newList; -(void)managePrintList; +-(void)manageListName; @end @@ -153,10 +170,15 @@ -(void)manageAddList:(ToDoList *)newList { -(void)managePrintList { for (int i = 0; i < [_manageMyList count]; i++) { - NSLog(@"Print master list: %@", [[_manageMyList objectAtIndex:i] listName]); + NSLog(@"Your %@ List", [[_manageMyList objectAtIndex:i] listName]); // this displays list categories, add items too - loop again +// for (int j=0; j< [[_manageMyList objectAtIndex:i] count]; j++) { +// +// } } } + + -(void)manageNewList { int addList; while (true) { @@ -166,7 +188,15 @@ -(void)manageNewList { //later we can add more functionality ie edit a list or delete a list if (addList == 1) { ToDoList *newList = [[ToDoList alloc] init]; +// NSLog(@"Please name your list:"); +// char name[256]; +// fgets(name, 256, stdin); +// NSString *item2 = [NSString stringWithUTF8String:name]; +// [self manageNewList]; +// NSLog(@"Now, let's add items to %s list!", name); + [newList addListTitle]; [newList createItems]; + [newList listName]; [self manageAddList:newList]; } else { @@ -177,7 +207,8 @@ -(void)manageNewList { } @end -// *** MAIN *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** +// *** MAIN *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** + int main(int argc, const char * argv[]) { @autoreleasepool { From 2458fad89a3e056edc77980d19f4eab1512f145c Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Sun, 28 Jun 2015 18:14:39 -0400 Subject: [PATCH 11/19] end of class updates --- TodoList/TodoList/main.m | 1 + 1 file changed, 1 insertion(+) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 42059f1..7405ae7 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -177,6 +177,7 @@ -(void)managePrintList { } } +// extra comment -(void)manageNewList { From de47e25ce7b18cc200336a75265293918977ea4e Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Mon, 29 Jun 2015 19:50:43 -0400 Subject: [PATCH 12/19] added the managelist and able to print out list and items --- TodoList/TodoList/main.m | 60 +++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 7405ae7..4222477 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -20,7 +20,9 @@ @interface ToDoItem : NSObject - (void)setItem:(NSString *)itemName; - (NSString *)itemName; -- (void)addNameAndPriority; +//- (void)addNameAndPriority; +- (void)addItemName; +- (void)addPriority; @end @implementation ToDoItem { @@ -42,26 +44,30 @@ - (int) priority { return _priority; } -- (void)addNameAndPriority { - +//- (void)addNameAndPriority { + +- (void)addItemName { NSLog(@"Enter item: "); // "fgets" allows the user to input an item with more than one word ie: "cat food" char name[256]; fgets(name, 256, stdin); - NSLog(@"item added: %s", name); // we test our work above here + // NSLog(@"item added: %s", name); // we test our work above here // we used "stringWithUTF8String" to convert char to string NSString *item1 = [NSString stringWithUTF8String:name]; // NSLog(@"string test: %@", item1); [self setItem: item1]; +} + +- (void)addPriority { // we set the priority level for each inputted item - NSLog(@"Enter priority 1 = hair on fire urgent, 2, 3, 4 = whatever, later: "); + NSLog(@"Enter priority level: 1 = hair on fire urgent, 2, 3, 4 = whatever, later: "); int inputPriority; scanf("%d", &inputPriority); [self setPriority: inputPriority]; // we print/test the inputted item name and priority - NSLog(@"priority level: %d", inputPriority); + // NSLog(@"priority level: %d", inputPriority); } @end @@ -93,11 +99,11 @@ -(void)addItem:(ToDoItem *)newItem { [[self myListedItems] addObject:newItem]; } --(void)printList { - for (int i = 0; i < [_myListedItems count]; i++) { - NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); - } -} +//-(void)printList { +// for (int i = 0; i < [_myListedItems count]; i++) { +// NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); +// } +//} - (void)createItems { int add; @@ -112,12 +118,19 @@ - (void)createItems { // created a new Item object and set its item/priority. This addes our item to the memory ToDoItem *newItem = [[ToDoItem alloc] init]; // this sends a message to add an item - [newItem addNameAndPriority]; + // [newItem addNameAndPriority]; + [newItem addItemName]; + [newItem addPriority]; // added the Item to `self`'s myListedItems array [self addItem:newItem]; } else { -// NSLog(@"Finished adding items"); + NSLog(@"Your Current List Contains:"); + + for (int i = 0; i < [_myListedItems count]; i++) { + NSLog(@"%@", [[_myListedItems objectAtIndex:i] itemName]); + } + break; } } @@ -148,7 +161,7 @@ @interface ManageList : NSObject -(NSMutableArray *)manageMyList; -(void)manageAddList:(ToDoList *)newList; -(void)managePrintList; --(void)manageListName; +//-(void)manageListName; @end @@ -170,10 +183,16 @@ -(void)manageAddList:(ToDoList *)newList { -(void)managePrintList { for (int i = 0; i < [_manageMyList count]; i++) { - NSLog(@"Your %@ List", [[_manageMyList objectAtIndex:i] listName]); // this displays list categories, add items too - loop again -// for (int j=0; j< [[_manageMyList objectAtIndex:i] count]; j++) { -// -// } + NSLog(@"Your %@", [[_manageMyList objectAtIndex:i] listName]); // this displays list categories, add items too - loop again + + ToDoList *list = [_manageMyList objectAtIndex:i]; + + for (int j=0; j< [list.myListedItems count]; j++) { + + ToDoItem *item = [list.myListedItems objectAtIndex:j]; + + NSLog(@"%@",item.itemName); + } } } @@ -217,10 +236,7 @@ int main(int argc, const char * argv[]) { [newList manageNewList]; [newList managePrintList]; -// ToDoList *addList = [[ToDoList alloc] init]; -// [addList createItems]; -// [addList printList]; - + } return 0; From 458891ae984186abc396bc652ef633e9c9181127 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Mon, 29 Jun 2015 21:45:03 -0400 Subject: [PATCH 13/19] office hours edits --- TodoList/TodoList/main.m | 66 +++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 4222477..e8bd631 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -3,7 +3,7 @@ // TodoList // // Created by Michael Kavouras on 6/25/15. -// Homework by Xiulan and Shena 6/27/15. +// Homework by Xiulan and Shena 6/29/15. // Copyright (c) 2015 Mike Kavouras. All rights reserved. // @@ -61,7 +61,11 @@ - (void)addItemName { - (void)addPriority { // we set the priority level for each inputted item - NSLog(@"Enter priority level: 1 = hair on fire urgent, 2, 3, 4 = whatever, later: "); + NSLog(@"Enter priority level:"); + NSLog(@"1 = hair on fire urgent"); + NSLog(@"2 = important"); + NSLog(@"3 = don't forget"); + NSLog(@"4 = whatever, just do it later"); int inputPriority; scanf("%d", &inputPriority); @@ -77,7 +81,9 @@ @interface ToDoList : NSObject -(NSMutableArray *)myListedItems; -(void)addItem:(ToDoItem *)newItem; --(void)printList; +//-(void)editItem:(ToDoItem *)editItem; +//-(void)deleteItem:(ToDoItem *)deleteItem; +//-(void)printList; -(void)setListName:(NSString *)listName; -(NSString *)listName; @end @@ -106,15 +112,21 @@ -(void)addItem:(ToDoItem *)newItem { //} - (void)createItems { - int add; + int choices, itemNo; // we started our while loop to add multiple items to the list + // when the program runs for the first time, we only want to offer the add item and quit options. while (true) { - NSLog(@"Enter 1 to add an item or 0 to quit:"); - scanf("%d", &add); + NSLog(@"Enter 1 to add an item."); + if ([_myListedItems count] != 0) { + NSLog(@"Enter 2 to edit an item."); + NSLog(@"Enter 3 to delete an item."); + } + NSLog(@"Enter 0 to quit."); + scanf("%d", &choices); // "fpurge" stopped our code from displaying all at once fpurge(stdin); // added "if" condition to allow the user to stop or continue adding items to list - if (add == 1) { + if (choices == 1) { // created a new Item object and set its item/priority. This addes our item to the memory ToDoItem *newItem = [[ToDoItem alloc] init]; // this sends a message to add an item @@ -124,17 +136,40 @@ - (void)createItems { // added the Item to `self`'s myListedItems array [self addItem:newItem]; + } else if (choices == 2) { + NSLog(@"Which item no to edit?"); + scanf("%d", &itemNo); + fpurge(stdin); + ToDoItem *newItem = [[ToDoItem alloc] init]; + // this sends a message to add an item + // [newItem addNameAndPriority]; + [newItem addItemName]; + [newItem addPriority]; + + [_myListedItems replaceObjectAtIndex:itemNo-1 withObject:newItem]; + } else if (choices == 3) { + NSLog(@"which item no to delete?"); + scanf("%d", &itemNo); + [_myListedItems removeObjectAtIndex:itemNo-1]; } else { NSLog(@"Your Current List Contains:"); - for (int i = 0; i < [_myListedItems count]; i++) { - NSLog(@"%@", [[_myListedItems objectAtIndex:i] itemName]); + NSLog(@"%d %@", i+1,[[_myListedItems objectAtIndex:i] itemName]); } break; } } } + +//-(void)editItem:(ToDoItem *)editItem +// atIndex:(NSInteger) e { +// editItem = e; +// [[self _myListedItems]replaceObjectAtIndex:editItem +// withObject: _editItem]; +//} +//-(void)deleteItem:(ToDoItem *)deleteItem; +// -(void)setListName:(NSString *)listName { _listName = listName; } @@ -191,18 +226,21 @@ -(void)managePrintList { ToDoItem *item = [list.myListedItems objectAtIndex:j]; - NSLog(@"%@",item.itemName); + NSLog(@"%d %@", j+1, item.itemName); } } } -// extra comment - - +// we set an if statement so that we only run options 2 and 3 once a list exists -(void)manageNewList { int addList; while (true) { - NSLog(@"Enter 1 to create a new list or 0 to quit:"); + NSLog(@"Enter 1 to create a new list."); + if ([_manageMyList count] != 0) { + NSLog(@"Enter 2 to edit a list."); + NSLog(@"Enter 3 to delete a list."); + } + NSLog(@"Enter 0 to quit."); scanf("%d", &addList); fpurge(stdin); //later we can add more functionality ie edit a list or delete a list From 291413d0d7e43bbe9c8b224366b87b3125fee622 Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Mon, 29 Jun 2015 22:34:06 -0400 Subject: [PATCH 14/19] added EDIT Delete Mark done --- TodoList/TodoList/main.m | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index e8bd631..2143b2b 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -28,6 +28,7 @@ - (void)addPriority; @implementation ToDoItem { NSString *_itemName; int _priority; + BOOL _isDone; } - (void)setItem:(NSString *)itemName { @@ -44,6 +45,14 @@ - (int) priority { return _priority; } +- (void)setIsDone:(BOOL)isDone { + _isDone = isDone; +} +- (BOOL)isDone { + return _isDone; +} + + //- (void)addNameAndPriority { - (void)addItemName { @@ -83,7 +92,7 @@ -(NSMutableArray *)myListedItems; -(void)addItem:(ToDoItem *)newItem; //-(void)editItem:(ToDoItem *)editItem; //-(void)deleteItem:(ToDoItem *)deleteItem; -//-(void)printList; +-(void)printList; -(void)setListName:(NSString *)listName; -(NSString *)listName; @end @@ -120,6 +129,7 @@ - (void)createItems { if ([_myListedItems count] != 0) { NSLog(@"Enter 2 to edit an item."); NSLog(@"Enter 3 to delete an item."); + NSLog(@"Enter 4 to mark item as done."); } NSLog(@"Enter 0 to quit."); scanf("%d", &choices); @@ -140,17 +150,27 @@ - (void)createItems { NSLog(@"Which item no to edit?"); scanf("%d", &itemNo); fpurge(stdin); - ToDoItem *newItem = [[ToDoItem alloc] init]; + ToDoItem *newItem = [_myListedItems objectAtIndex:itemNo-1]; // this sends a message to add an item // [newItem addNameAndPriority]; [newItem addItemName]; [newItem addPriority]; - - [_myListedItems replaceObjectAtIndex:itemNo-1 withObject:newItem]; } else if (choices == 3) { NSLog(@"which item no to delete?"); scanf("%d", &itemNo); [_myListedItems removeObjectAtIndex:itemNo-1]; + } else if (choices == 4) { + NSLog(@"which item no to mark as done?"); + scanf("%d", &itemNo); + fpurge(stdin); + ToDoItem *newItem = [_myListedItems objectAtIndex:itemNo-1]; + [newItem setIsDone:YES]; + + if([newItem isDone]) + NSLog(@"%@ done", [newItem itemName]); + + // NSLog(@"%@ is %d where 1 = done",[newItem itemName],[newItem isDone]); + } else { NSLog(@"Your Current List Contains:"); for (int i = 0; i < [_myListedItems count]; i++) { From 6524d0f8187053adc2b2a2113eaa8096916d3b2b Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Tue, 30 Jun 2015 18:48:17 -0400 Subject: [PATCH 15/19] adding completion date --- TodoList/TodoList/main.m | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 2143b2b..9c6fcc1 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -9,7 +9,7 @@ #import -// *** CLASS DECLERATIONS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** +// *** CLASS DECLERATIONS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** @class ToDoItem; @class ToDoList; @@ -23,12 +23,16 @@ - (NSString *)itemName; //- (void)addNameAndPriority; - (void)addItemName; - (void)addPriority; +- (BOOL)isDone; +- (void)makeAsDone:(BOOL)isDone; +- (void)setCompletionDate; @end @implementation ToDoItem { NSString *_itemName; int _priority; BOOL _isDone; + NSDate *_completionDate; } - (void)setItem:(NSString *)itemName { @@ -51,6 +55,18 @@ - (void)setIsDone:(BOOL)isDone { - (BOOL)isDone { return _isDone; } +- (void)makeAsDone:(BOOL)isDone { + self.isDone = isDone; + [self setCompletionDate]; +} +- (void)setCompletionDate { + if (self.isDone){ + _completionDate = [NSDate date]; + } else { + _completionDate = nil; + } +} + //- (void)addNameAndPriority { @@ -80,8 +96,9 @@ - (void)addPriority { [self setPriority: inputPriority]; // we print/test the inputted item name and priority - // NSLog(@"priority level: %d", inputPriority); + // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); } + @end // *** TO DO LIST CLASS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** *** *** *** @@ -114,11 +131,12 @@ -(void)addItem:(ToDoItem *)newItem { [[self myListedItems] addObject:newItem]; } -//-(void)printList { -// for (int i = 0; i < [_myListedItems count]; i++) { -// NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); -// } -//} +// uncommented this, maybe test it +-(void)printList { + for (int i = 0; i < [_myListedItems count]; i++) { + NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); + } +} - (void)createItems { int choices, itemNo; @@ -147,7 +165,7 @@ - (void)createItems { // added the Item to `self`'s myListedItems array [self addItem:newItem]; } else if (choices == 2) { - NSLog(@"Which item no to edit?"); + NSLog(@"Enter item number to edit:"); scanf("%d", &itemNo); fpurge(stdin); ToDoItem *newItem = [_myListedItems objectAtIndex:itemNo-1]; @@ -156,11 +174,11 @@ - (void)createItems { [newItem addItemName]; [newItem addPriority]; } else if (choices == 3) { - NSLog(@"which item no to delete?"); + NSLog(@"Enter item number to delete:"); scanf("%d", &itemNo); [_myListedItems removeObjectAtIndex:itemNo-1]; } else if (choices == 4) { - NSLog(@"which item no to mark as done?"); + NSLog(@"Enter item number to mark as done:"); scanf("%d", &itemNo); fpurge(stdin); ToDoItem *newItem = [_myListedItems objectAtIndex:itemNo-1]; @@ -175,6 +193,7 @@ - (void)createItems { NSLog(@"Your Current List Contains:"); for (int i = 0; i < [_myListedItems count]; i++) { NSLog(@"%d %@", i+1,[[_myListedItems objectAtIndex:i] itemName]); + // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); } break; From 15fe30cc217bf92c5026c3345d79dd7287830925 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Wed, 1 Jul 2015 18:34:14 -0400 Subject: [PATCH 16/19] wednesday updates --- TodoList/TodoList/main.m | 67 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 9c6fcc1..106fa39 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -11,13 +11,14 @@ // *** CLASS DECLERATIONS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** -@class ToDoItem; -@class ToDoList; -@class ManageList; +@class ToDoItem; // 1st class manages list items +@class ToDoList; // 2nd class manages individual lists +@class ManageList; // 3rd class manages list commands -// *** TO DO ITEM CLASS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** +// *** 1. TO DO ITEM *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** @interface ToDoItem : NSObject + - (void)setItem:(NSString *)itemName; - (NSString *)itemName; //- (void)addNameAndPriority; @@ -26,6 +27,7 @@ - (void)addPriority; - (BOOL)isDone; - (void)makeAsDone:(BOOL)isDone; - (void)setCompletionDate; + @end @implementation ToDoItem { @@ -77,7 +79,7 @@ - (void)addItemName { char name[256]; fgets(name, 256, stdin); - // NSLog(@"item added: %s", name); // we test our work above here + // NSLog(@"item added: %s", name); // we test our work above here // we used "stringWithUTF8String" to convert char to string NSString *item1 = [NSString stringWithUTF8String:name]; // NSLog(@"string test: %@", item1); @@ -86,11 +88,7 @@ - (void)addItemName { - (void)addPriority { // we set the priority level for each inputted item - NSLog(@"Enter priority level:"); - NSLog(@"1 = hair on fire urgent"); - NSLog(@"2 = important"); - NSLog(@"3 = don't forget"); - NSLog(@"4 = whatever, just do it later"); + NSLog(@"Enter priority level 1-4:"); int inputPriority; scanf("%d", &inputPriority); @@ -101,7 +99,7 @@ - (void)addPriority { @end -// *** TO DO LIST CLASS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** *** *** *** +// *** 2. TO DO LIST *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** *** *** *** @interface ToDoList : NSObject @@ -158,10 +156,10 @@ - (void)createItems { // created a new Item object and set its item/priority. This addes our item to the memory ToDoItem *newItem = [[ToDoItem alloc] init]; // this sends a message to add an item - // [newItem addNameAndPriority]; + // [newItem addNameAndPriority]; [newItem addItemName]; [newItem addPriority]; - + // added the Item to `self`'s myListedItems array [self addItem:newItem]; } else if (choices == 2) { @@ -184,17 +182,17 @@ - (void)createItems { ToDoItem *newItem = [_myListedItems objectAtIndex:itemNo-1]; [newItem setIsDone:YES]; - if([newItem isDone]) - NSLog(@"%@ done", [newItem itemName]); + if([newItem isDone]) + NSLog(@"%@ done", [newItem itemName]); + + // NSLog(@"%@ is %d where 1 = done",[newItem itemName],[newItem isDone]); - // NSLog(@"%@ is %d where 1 = done",[newItem itemName],[newItem isDone]); - } else { NSLog(@"Your Current List Contains:"); - for (int i = 0; i < [_myListedItems count]; i++) { - NSLog(@"%d %@", i+1,[[_myListedItems objectAtIndex:i] itemName]); - // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); - } + for (int i = 0; i < [_myListedItems count]; i++) { + NSLog(@"%d %@", i+1,[[_myListedItems objectAtIndex:i] itemName]); + // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); + } break; } @@ -216,22 +214,23 @@ -(NSString *)listName { return _listName; } -(void)addListTitle { -// NSLog(@"Enter 1 to create a new list or 0 to quit:"); + // NSLog(@"Enter 1 to create a new list or 0 to quit:"); NSLog(@"Please name your list:"); char name[256]; fgets(name, 256, stdin); -// NSLog(@"%s: list name", name); + // NSLog(@"%s: list name", name); NSString *item2 = [NSString stringWithUTF8String:name]; [self setListName: item2]; NSLog(@"Now, let's add items to %s list!", name); - + } @end -// *** MANAGE LIST CLASS *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** *** *** *** +// *** 3. MANAGE LIST *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** *** *** *** *** *** @interface ManageList : NSObject + -(NSMutableArray *)manageMyList; -(void)manageAddList:(ToDoList *)newList; -(void)managePrintList; @@ -285,12 +284,12 @@ -(void)manageNewList { //later we can add more functionality ie edit a list or delete a list if (addList == 1) { ToDoList *newList = [[ToDoList alloc] init]; -// NSLog(@"Please name your list:"); -// char name[256]; -// fgets(name, 256, stdin); -// NSString *item2 = [NSString stringWithUTF8String:name]; -// [self manageNewList]; -// NSLog(@"Now, let's add items to %s list!", name); + // NSLog(@"Please name your list:"); + // char name[256]; + // fgets(name, 256, stdin); + // NSString *item2 = [NSString stringWithUTF8String:name]; + // [self manageNewList]; + // NSLog(@"Now, let's add items to %s list!", name); [newList addListTitle]; [newList createItems]; [newList listName]; @@ -313,8 +312,8 @@ int main(int argc, const char * argv[]) { [newList manageNewList]; [newList managePrintList]; - - - } + + + } return 0; } From 63fbfad41236fb5e0d403de034f08e27608c8473 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Wed, 1 Jul 2015 20:45:27 -0400 Subject: [PATCH 17/19] first draft --- TodoList/TodoList/main.m | 73 +++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 106fa39..de465e9 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -21,12 +21,10 @@ @interface ToDoItem : NSObject - (void)setItem:(NSString *)itemName; - (NSString *)itemName; -//- (void)addNameAndPriority; - (void)addItemName; - (void)addPriority; - (BOOL)isDone; -- (void)makeAsDone:(BOOL)isDone; -- (void)setCompletionDate; + @end @@ -34,7 +32,6 @@ @implementation ToDoItem { NSString *_itemName; int _priority; BOOL _isDone; - NSDate *_completionDate; } - (void)setItem:(NSString *)itemName { @@ -44,10 +41,10 @@ - (NSString *)itemName { return _itemName; } -- (void)setPriority: (int) priority { - _priority = priority; +- (void)setPriority: (int)itemPriority { + _priority = itemPriority; } -- (int) priority { +- (int)itemPriority { return _priority; } @@ -57,21 +54,6 @@ - (void)setIsDone:(BOOL)isDone { - (BOOL)isDone { return _isDone; } -- (void)makeAsDone:(BOOL)isDone { - self.isDone = isDone; - [self setCompletionDate]; -} -- (void)setCompletionDate { - if (self.isDone){ - _completionDate = [NSDate date]; - } else { - _completionDate = nil; - } -} - - - -//- (void)addNameAndPriority { - (void)addItemName { NSLog(@"Enter item: "); @@ -82,13 +64,22 @@ - (void)addItemName { // NSLog(@"item added: %s", name); // we test our work above here // we used "stringWithUTF8String" to convert char to string NSString *item1 = [NSString stringWithUTF8String:name]; + item1 = [item1 stringByReplacingOccurrencesOfString:@"\n" withString:@""]; // NSLog(@"string test: %@", item1); [self setItem: item1]; } +- (NSString *) description { + NSString* done = @"Not Done"; + if (self.isDone) { + done = @"Done!"; + } + return [[NSString alloc] initWithFormat:@"%@ with priority level %d %@.", _itemName, _priority, done]; +} + - (void)addPriority { // we set the priority level for each inputted item - NSLog(@"Enter priority level 1-4:"); + NSLog(@"New priority level 1-4:"); int inputPriority; scanf("%d", &inputPriority); @@ -110,6 +101,8 @@ -(void)addItem:(ToDoItem *)newItem; -(void)printList; -(void)setListName:(NSString *)listName; -(NSString *)listName; +- (void)printAllListItems; + @end @implementation ToDoList { @@ -136,6 +129,16 @@ -(void)printList { } } +- (void)printAllListItems { + NSLog(@"Your Current List Contains:"); + + + for (int i = 0; i < [_myListedItems count]; i++) { + NSLog(@"%d. %@", i+1, [_myListedItems objectAtIndex:i] ); + } +} + + - (void)createItems { int choices, itemNo; // we started our while loop to add multiple items to the list @@ -155,14 +158,16 @@ - (void)createItems { if (choices == 1) { // created a new Item object and set its item/priority. This addes our item to the memory ToDoItem *newItem = [[ToDoItem alloc] init]; + [newItem setPriority:1]; // this sends a message to add an item // [newItem addNameAndPriority]; [newItem addItemName]; - [newItem addPriority]; + // [newItem addPriority]; // added the Item to `self`'s myListedItems array [self addItem:newItem]; } else if (choices == 2) { + [self printAllListItems]; NSLog(@"Enter item number to edit:"); scanf("%d", &itemNo); fpurge(stdin); @@ -172,10 +177,12 @@ - (void)createItems { [newItem addItemName]; [newItem addPriority]; } else if (choices == 3) { + [self printAllListItems]; NSLog(@"Enter item number to delete:"); scanf("%d", &itemNo); [_myListedItems removeObjectAtIndex:itemNo-1]; } else if (choices == 4) { + [self printAllListItems]; NSLog(@"Enter item number to mark as done:"); scanf("%d", &itemNo); fpurge(stdin); @@ -187,15 +194,19 @@ - (void)createItems { // NSLog(@"%@ is %d where 1 = done",[newItem itemName],[newItem isDone]); - } else { - NSLog(@"Your Current List Contains:"); - for (int i = 0; i < [_myListedItems count]; i++) { - NSLog(@"%d %@", i+1,[[_myListedItems objectAtIndex:i] itemName]); - // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); - } - + } else if (choices == 0){ +// NSLog(@"Your Current List Contains:"); +// for (int i = 0; i < [_myListedItems count]; i++) { +// NSLog(@"%d %@", i+1,[[_myListedItems objectAtIndex:i] itemName]); +// // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); +// } + //a quit message + [self printAllListItems]; break; + } else { + NSLog(@"Please enter 0 - 4"); } + } } From a2096da2330b0428bae3b5118b4cb3f71c3ab17c Mon Sep 17 00:00:00 2001 From: Xiulan Shi Date: Wed, 1 Jul 2015 21:47:24 -0400 Subject: [PATCH 18/19] final --- TodoList/TodoList/main.m | 124 +++++++++++---------------------------- 1 file changed, 34 insertions(+), 90 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index de465e9..39087e6 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -3,7 +3,7 @@ // TodoList // // Created by Michael Kavouras on 6/25/15. -// Homework by Xiulan and Shena 6/29/15. +// Homework by Xiulan 💁🏻 and Shena 🙋🏻 6/29/15. // Copyright (c) 2015 Mike Kavouras. All rights reserved. // @@ -57,35 +57,26 @@ - (BOOL)isDone { - (void)addItemName { NSLog(@"Enter item: "); - // "fgets" allows the user to input an item with more than one word ie: "cat food" char name[256]; - fgets(name, 256, stdin); - - // NSLog(@"item added: %s", name); // we test our work above here - // we used "stringWithUTF8String" to convert char to string - NSString *item1 = [NSString stringWithUTF8String:name]; + fgets(name, 256, stdin); // "fgets" allows the user to input an item with more than one word ie: "cat food" + NSString *item1 = [NSString stringWithUTF8String:name]; // we used "stringWithUTF8String" to convert char to string item1 = [item1 stringByReplacingOccurrencesOfString:@"\n" withString:@""]; - // NSLog(@"string test: %@", item1); [self setItem: item1]; } - (NSString *) description { - NSString* done = @"Not Done"; + NSString* done = @"(not done)"; if (self.isDone) { - done = @"Done!"; + done = @"(done)"; } - return [[NSString alloc] initWithFormat:@"%@ with priority level %d %@.", _itemName, _priority, done]; + return [[NSString alloc] initWithFormat:@"%@, priority %d %@", _itemName, _priority, done]; } -- (void)addPriority { - // we set the priority level for each inputted item +- (void)addPriority { // we set the priority level for each inputted item NSLog(@"New priority level 1-4:"); int inputPriority; scanf("%d", &inputPriority); - [self setPriority: inputPriority]; - // we print/test the inputted item name and priority - // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); } @end @@ -96,9 +87,7 @@ @interface ToDoList : NSObject -(NSMutableArray *)myListedItems; -(void)addItem:(ToDoItem *)newItem; -//-(void)editItem:(ToDoItem *)editItem; -//-(void)deleteItem:(ToDoItem *)deleteItem; --(void)printList; +//-(void)printList; -(void)setListName:(NSString *)listName; -(NSString *)listName; - (void)printAllListItems; @@ -110,10 +99,9 @@ @implementation ToDoList { NSString *_listName; } -//initialize our list of items: -(NSMutableArray *)myListedItems { if (_myListedItems == nil) { - _myListedItems = [[NSMutableArray alloc] init]; + _myListedItems = [[NSMutableArray alloc] init]; //initialize our list of items: } return _myListedItems; } @@ -123,57 +111,44 @@ -(void)addItem:(ToDoItem *)newItem { } // uncommented this, maybe test it --(void)printList { - for (int i = 0; i < [_myListedItems count]; i++) { - NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); - } -} +//-(void)printList { +// for (int i = 0; i < [_myListedItems count]; i++) { +// NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); +// } +//} - (void)printAllListItems { NSLog(@"Your Current List Contains:"); - - for (int i = 0; i < [_myListedItems count]; i++) { NSLog(@"%d. %@", i+1, [_myListedItems objectAtIndex:i] ); } } - - (void)createItems { int choices, itemNo; - // we started our while loop to add multiple items to the list - // when the program runs for the first time, we only want to offer the add item and quit options. - while (true) { + while (true) { // we started our while loop to add multiple items to the list NSLog(@"Enter 1 to add an item."); - if ([_myListedItems count] != 0) { + if ([_myListedItems count] != 0) { // when the program runs for the first time, we only want to offer the add item and quit options. NSLog(@"Enter 2 to edit an item."); NSLog(@"Enter 3 to delete an item."); NSLog(@"Enter 4 to mark item as done."); } NSLog(@"Enter 0 to quit."); scanf("%d", &choices); - // "fpurge" stopped our code from displaying all at once - fpurge(stdin); - // added "if" condition to allow the user to stop or continue adding items to list - if (choices == 1) { - // created a new Item object and set its item/priority. This addes our item to the memory - ToDoItem *newItem = [[ToDoItem alloc] init]; + fpurge(stdin); // "fpurge" stopped our code from displaying all at once + if (choices == 1) { // added "if" condition to allow the user to stop or continue adding items to list + + ToDoItem *newItem = [[ToDoItem alloc] init]; // created a new Item object and set its item/priority. This addes our item to the memory [newItem setPriority:1]; - // this sends a message to add an item - // [newItem addNameAndPriority]; [newItem addItemName]; - // [newItem addPriority]; - - // added the Item to `self`'s myListedItems array - [self addItem:newItem]; + [self addItem:newItem]; // added the Item to `self`'s myListedItems array + } else if (choices == 2) { [self printAllListItems]; - NSLog(@"Enter item number to edit:"); + NSLog(@"Enter item number to edit/prioritize:"); scanf("%d", &itemNo); fpurge(stdin); ToDoItem *newItem = [_myListedItems objectAtIndex:itemNo-1]; - // this sends a message to add an item - // [newItem addNameAndPriority]; [newItem addItemName]; [newItem addPriority]; } else if (choices == 3) { @@ -185,39 +160,23 @@ - (void)createItems { [self printAllListItems]; NSLog(@"Enter item number to mark as done:"); scanf("%d", &itemNo); - fpurge(stdin); + fpurge(stdin); // this prevents the code from displaying all at once ToDoItem *newItem = [_myListedItems objectAtIndex:itemNo-1]; [newItem setIsDone:YES]; if([newItem isDone]) NSLog(@"%@ done", [newItem itemName]); - // NSLog(@"%@ is %d where 1 = done",[newItem itemName],[newItem isDone]); - } else if (choices == 0){ -// NSLog(@"Your Current List Contains:"); -// for (int i = 0; i < [_myListedItems count]; i++) { -// NSLog(@"%d %@", i+1,[[_myListedItems objectAtIndex:i] itemName]); -// // NSLog(@"priority level: %d %@ %@", inputPriority, _itemName, _completionDate); -// } - //a quit message [self printAllListItems]; + NSLog(@"End of list.\n"); break; } else { NSLog(@"Please enter 0 - 4"); } - } } -//-(void)editItem:(ToDoItem *)editItem -// atIndex:(NSInteger) e { -// editItem = e; -// [[self _myListedItems]replaceObjectAtIndex:editItem -// withObject: _editItem]; -//} -//-(void)deleteItem:(ToDoItem *)deleteItem; -// -(void)setListName:(NSString *)listName { _listName = listName; } @@ -225,15 +184,13 @@ -(NSString *)listName { return _listName; } -(void)addListTitle { - // NSLog(@"Enter 1 to create a new list or 0 to quit:"); NSLog(@"Please name your list:"); char name[256]; fgets(name, 256, stdin); - // NSLog(@"%s: list name", name); NSString *item2 = [NSString stringWithUTF8String:name]; + item2 = [item2 stringByReplacingOccurrencesOfString:@"\n" withString:@""]; [self setListName: item2]; NSLog(@"Now, let's add items to %s list!", name); - } @end @@ -245,7 +202,6 @@ @interface ManageList : NSObject -(NSMutableArray *)manageMyList; -(void)manageAddList:(ToDoList *)newList; -(void)managePrintList; -//-(void)manageListName; @end @@ -253,10 +209,9 @@ @implementation ManageList { NSMutableArray *_manageMyList; } -//initialize manageMylist -(NSMutableArray *)manageMyList { if (_manageMyList == nil) { - _manageMyList = [[NSMutableArray alloc] init]; + _manageMyList = [[NSMutableArray alloc] init]; //initialize manageMylist } return _manageMyList; } @@ -267,7 +222,7 @@ -(void)manageAddList:(ToDoList *)newList { -(void)managePrintList { for (int i = 0; i < [_manageMyList count]; i++) { - NSLog(@"Your %@", [[_manageMyList objectAtIndex:i] listName]); // this displays list categories, add items too - loop again + NSLog(@"Your %@ List:", [[_manageMyList objectAtIndex:i] listName]); // this displays list categories, add items too - loop again ToDoList *list = [_manageMyList objectAtIndex:i]; @@ -275,40 +230,30 @@ -(void)managePrintList { ToDoItem *item = [list.myListedItems objectAtIndex:j]; - NSLog(@"%d %@", j+1, item.itemName); + NSLog(@"%d. %@", j+1, item); } } } -// we set an if statement so that we only run options 2 and 3 once a list exists -(void)manageNewList { int addList; while (true) { NSLog(@"Enter 1 to create a new list."); - if ([_manageMyList count] != 0) { - NSLog(@"Enter 2 to edit a list."); - NSLog(@"Enter 3 to delete a list."); - } NSLog(@"Enter 0 to quit."); scanf("%d", &addList); fpurge(stdin); - //later we can add more functionality ie edit a list or delete a list + if (addList == 1) { ToDoList *newList = [[ToDoList alloc] init]; - // NSLog(@"Please name your list:"); - // char name[256]; - // fgets(name, 256, stdin); - // NSString *item2 = [NSString stringWithUTF8String:name]; - // [self manageNewList]; - // NSLog(@"Now, let's add items to %s list!", name); [newList addListTitle]; [newList createItems]; [newList listName]; - [self manageAddList:newList]; - } else { - NSLog(@"Good bye!"); + + } else if (addList == 0) { break; + } else { + NSLog(@"Please enter 0 or 1."); } } } @@ -324,7 +269,6 @@ int main(int argc, const char * argv[]) { [newList manageNewList]; [newList managePrintList]; - } return 0; } From f848c3d6801c4327e8dffc1675b5bafda4f9dfd4 Mon Sep 17 00:00:00 2001 From: Shena Yoshida Date: Thu, 2 Jul 2015 18:36:44 -0400 Subject: [PATCH 19/19] presentation notes --- TodoList/TodoList/main.m | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 39087e6..6c7c28f 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -60,7 +60,7 @@ - (void)addItemName { char name[256]; fgets(name, 256, stdin); // "fgets" allows the user to input an item with more than one word ie: "cat food" NSString *item1 = [NSString stringWithUTF8String:name]; // we used "stringWithUTF8String" to convert char to string - item1 = [item1 stringByReplacingOccurrencesOfString:@"\n" withString:@""]; + item1 = [item1 stringByReplacingOccurrencesOfString:@"\n" withString:@""]; // this line eliminated the automatic linebreak that was caused by the stringWithUTF8 function [self setItem: item1]; } @@ -87,7 +87,6 @@ @interface ToDoList : NSObject -(NSMutableArray *)myListedItems; -(void)addItem:(ToDoItem *)newItem; -//-(void)printList; -(void)setListName:(NSString *)listName; -(NSString *)listName; - (void)printAllListItems; @@ -101,7 +100,7 @@ @implementation ToDoList { -(NSMutableArray *)myListedItems { if (_myListedItems == nil) { - _myListedItems = [[NSMutableArray alloc] init]; //initialize our list of items: + _myListedItems = [[NSMutableArray alloc] init]; // initialize our list of items: } return _myListedItems; } @@ -110,16 +109,9 @@ -(void)addItem:(ToDoItem *)newItem { [[self myListedItems] addObject:newItem]; } -// uncommented this, maybe test it -//-(void)printList { -// for (int i = 0; i < [_myListedItems count]; i++) { -// NSLog(@"print test:%@", [[_myListedItems objectAtIndex:i] itemName]); -// } -//} - - (void)printAllListItems { NSLog(@"Your Current List Contains:"); - for (int i = 0; i < [_myListedItems count]; i++) { + for (int i = 0; i < [_myListedItems count]; i++) { // created a for loop to display each item in the list NSLog(@"%d. %@", i+1, [_myListedItems objectAtIndex:i] ); } } @@ -128,7 +120,7 @@ - (void)createItems { int choices, itemNo; while (true) { // we started our while loop to add multiple items to the list NSLog(@"Enter 1 to add an item."); - if ([_myListedItems count] != 0) { // when the program runs for the first time, we only want to offer the add item and quit options. + if ([_myListedItems count] != 0) { // when list is empty, we don't want all 5 options to be displayed NSLog(@"Enter 2 to edit an item."); NSLog(@"Enter 3 to delete an item."); NSLog(@"Enter 4 to mark item as done."); @@ -172,7 +164,7 @@ - (void)createItems { NSLog(@"End of list.\n"); break; } else { - NSLog(@"Please enter 0 - 4"); + NSLog(@"Please enter 0 - 4"); // controls incorrect user input } } } @@ -187,8 +179,8 @@ -(void)addListTitle { NSLog(@"Please name your list:"); char name[256]; fgets(name, 256, stdin); - NSString *item2 = [NSString stringWithUTF8String:name]; - item2 = [item2 stringByReplacingOccurrencesOfString:@"\n" withString:@""]; + NSString *item2 = [NSString stringWithUTF8String:name]; // converted char to NSString with the "stringWithUTF8Stirng" function + item2 = [item2 stringByReplacingOccurrencesOfString:@"\n" withString:@""]; // this line corrects spacing issues [self setListName: item2]; NSLog(@"Now, let's add items to %s list!", name); } @@ -223,13 +215,9 @@ -(void)manageAddList:(ToDoList *)newList { -(void)managePrintList { for (int i = 0; i < [_manageMyList count]; i++) { NSLog(@"Your %@ List:", [[_manageMyList objectAtIndex:i] listName]); // this displays list categories, add items too - loop again - ToDoList *list = [_manageMyList objectAtIndex:i]; - for (int j=0; j< [list.myListedItems count]; j++) { - ToDoItem *item = [list.myListedItems objectAtIndex:j]; - NSLog(@"%d. %@", j+1, item); } }