From fc21d9ace1239bbd13b45cd44134d17721bd0820 Mon Sep 17 00:00:00 2001 From: Artur Lane Date: Sat, 27 Jun 2015 14:19:28 -0400 Subject: [PATCH 1/4] First commit --- TodoList/TodoList/main.m | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 187be40..62ee019 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -8,10 +8,66 @@ #import + +@interface ToDoList: NSObject + +@property NSMutableArray *_taskArray; + + +-(void)listItems:(NSMutableArray *)listItems; +-(NSMutableArray *)listItems; + + +//-(void)addItems:(NSMutableArray *)addItems; +//-(NSString *)addItems; +// +//-(void)removeItems:(NSMutableArray *)removeItems; +////removeItems; +// +//-(void)markItemDone:(NSMutableArray *)markItemDone; +//-(NSMutableArray *)listItems; +// +//-(void)listCompletedItem:(NSMutableArray *)listCompletedItem; +//-(NSMutableArray *)listCompletedItem; + + +@end + + +@implementation ToDoList + +-(void)listItems:(NSMutableArray *)listItems { + + for(int counter=0; counter<=[listItems count]; counter++){ + NSLog(@"%c", listItems[counter].name); + + } + +} +@end + +//////////////////// + +@interface Item: NSObject + +@end + +@implementation Item + + +@end + +//// + + int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); + + + + } return 0; } From 44f4572d2d2cf43a32a9c35187909725684c0cec Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Thu, 2 Jul 2015 19:11:36 -0400 Subject: [PATCH 2/4] changes --- unit-0-final-project | 1 + 1 file changed, 1 insertion(+) create mode 160000 unit-0-final-project diff --git a/unit-0-final-project b/unit-0-final-project new file mode 160000 index 0000000..483cfe9 --- /dev/null +++ b/unit-0-final-project @@ -0,0 +1 @@ +Subproject commit 483cfe9d355d1005ae551bb4c87e013f29d50b81 From 2b0de366fb9209e59499f3d3d32bc2b85e2a9b85 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Mon, 6 Jul 2015 13:32:24 -0400 Subject: [PATCH 3/4] cheanges made --- unit-0-final-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-0-final-project b/unit-0-final-project index 483cfe9..270d267 160000 --- a/unit-0-final-project +++ b/unit-0-final-project @@ -1 +1 @@ -Subproject commit 483cfe9d355d1005ae551bb4c87e013f29d50b81 +Subproject commit 270d2673d957ec91c2ff29dc519c9c6027666f73 From e7bbb2a8a95fd6393835b93c6a8570c8a0999b6f Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Mon, 6 Jul 2015 13:41:13 -0400 Subject: [PATCH 4/4] might have commited an older one before --- TodoList/TodoList/main.m | 425 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 394 insertions(+), 31 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 62ee019..0ca16cb 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -1,73 +1,436 @@ // // main.m -// TodoList +// 3rdRoundTodoList // -// Created by Michael Kavouras on 6/25/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// Created by Bereket on 6/29/15. +// Copyright (c) 2015 Bereket . All rights reserved. // #import +@interface Item : NSObject -@interface ToDoList: NSObject +-(void)setPriorityValue:(NSInteger)priorityValue; +- (NSInteger)priorityValue; -@property NSMutableArray *_taskArray; +-(void)setTask:(NSString *)task; --(void)listItems:(NSMutableArray *)listItems; --(NSMutableArray *)listItems; +- (NSString*) itemName ; +-(void)setIsDone:(BOOL)isDone; +-(BOOL)isDone; //<-------property will inform us whether task is completed. -//-(void)addItems:(NSMutableArray *)addItems; -//-(NSString *)addItems; -// -//-(void)removeItems:(NSMutableArray *)removeItems; -////removeItems; -// -//-(void)markItemDone:(NSMutableArray *)markItemDone; -//-(NSMutableArray *)listItems; -// -//-(void)listCompletedItem:(NSMutableArray *)listCompletedItem; -//-(NSMutableArray *)listCompletedItem; +@end +@implementation Item { + NSInteger _priorityValue; + NSString* _task; + BOOL _isDone; +} + +-(void)setPriorityValue:(NSInteger)priorityValue{ + _priorityValue=priorityValue; +} + +-(NSInteger)priorityValue{ + return _priorityValue; +} +-(void)setTask:(NSString *)task{ + _task=task; +} +-(NSString*)itemName{ + return _task; +} + +-(void)setIsDone:(BOOL)isDone{ + _isDone=isDone; +} +-(BOOL)isDone{ + return _isDone; +} @end +//-------------------------------------------------------------------------------------------------------------------------------------// -@implementation ToDoList +//-------------------------------------------CLASS THAT DEFINES A LIST----------------------------------------------------------------// --(void)listItems:(NSMutableArray *)listItems { - - for(int counter=0; counter<=[listItems count]; counter++){ - NSLog(@"%c", listItems[counter].name); +@interface List : NSObject + +-(void)setListName:(NSString*)listName; +-(NSString*)listName; +-(void)printListItems; +-(void)addItem; +-(void)addItemWithName:(NSString *)name withPriority:(NSInteger)priority; +-(void)printCompletedItems; +-(void)printIncompletedItems; +-(void)removeItemFromList; +-(void)setlistIsDone:(BOOL)value; +-(BOOL)listIsDone; +-(void)manageList; + + +@end + +@implementation List{ + NSString* _listName; + NSMutableArray* _listItems; + BOOL listIsDone; +} + +-(void)manageList{ + while (true) { + + + NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; + NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + NSInteger input=[inputLine integerValue]; + NSLog(@"What would you like to do? PRESS 1 to show all items\n 2 to add an item\n 3 to set a list as done\n 4 to remove an item\n"); + + + switch (input) { + case 0: + NSLog(@"NICE JOB ORGANIZING THIS LIST"); + break; + + case 1: + [self printListItems]; + break; + + case 2: + [self addItem]; + break; + + case 3:{ + NSLog(@"Pick an item"); + + char doneList[200]; + scanf("%s",doneList); + NSString *markedName = [NSString stringWithUTF8String:doneList]; + for(int counter=0; counter< [_listItems count]; counter++){ + if ([[_listItems[counter] itemName] isEqualToString: markedName]) { + [_listItems[counter] setIsDone:YES]; + } + } + break; + } + + case 4: + [self removeItemFromList]; + break; + + default: + NSLog(@"YO you messed up ma G"); + break; + } + + } + + + + +} + + +-(void)addItemWithName:(NSString *)name withPriority:(NSInteger)priority{ + +} + + +-(void)setListName:(NSString *)listName{ + _listName=listName; +} + +-(NSString*)listName{ + return _listName; +} + +-(void)printListItems{ + for(int count=0;count<[_listItems count]; count++) + { + NSLog(@"%@, %ld", [_listItems[count] itemName],[_listItems[count] priorityValue]); + } +} + +-(void)addItem { //the AddItem Function will accept two values because the "Item" class has 2 properties + if (_listItems==nil) { //<----this conditional exists because the first time the method is called it wont be able + _listItems = [[NSMutableArray alloc] init]; //to return an array. Essentially, it says, "If there is no array, make one!" } + NSLog(@"What do you want to call this item?"); + + NSFileHandle *firstInput = [NSFileHandle fileHandleWithStandardInput]; + NSString *name = [[[NSString alloc] initWithData:firstInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + NSLog(@"What is this items priority?"); + + NSFileHandle *secondInput = [NSFileHandle fileHandleWithStandardInput]; + NSString *priority = [[[NSString alloc] initWithData:secondInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + NSInteger priorityIntegerValue = [priority integerValue]; + + + Item* newItem= [[Item alloc] init]; + [newItem setTask:name]; + [newItem setPriorityValue:priorityIntegerValue]; + + [_listItems addObject:newItem]; + +} + +-(void)printCompletedItems{ + for(int count=0;count<[_listItems count]; count++) + { + if([_listItems[count] isDone]) { //BOOLS default to false so it should print out all completed tasks + NSLog(@"%@, %ld", [_listItems[count] task],(long)[_listItems[count] priorityValue]); + }// + } +} + +-(void)printIncompletedItems{ + for(int count=0;count<[_listItems count]; count++) + { + if(![_listItems[count] isDone]) { //Just like in the previous methodsthe "!" tells us if it is not done + NSLog(@"%@, %ld", [_listItems[count] task],[_listItems[count] priorityValue]); + }// + } +} + +-(void)removeItemFromList{ + + NSFileHandle *input = [NSFileHandle fileHandleWithStandardInput]; + NSString *indexString = [[[NSString alloc] initWithData:input.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + NSInteger index = [indexString integerValue]; + + [_listItems removeObjectAtIndex:index]; +} + +-(void)setlistIsDone:(BOOL)value{ + listIsDone=value; } + +-(BOOL)listIsDone{ + return listIsDone; +} + @end -//////////////////// +//---------------------------------------------------------------------------------------------------------------------------------------------// -@interface Item: NSObject +//------------------------------CLASS THAT DEFINES THE TASK MANAGER (or the list of lists)---------------------------------------------------// +// +@interface TaskManager : NSObject +-(void)addList; +-(NSMutableArray*)getLists; +-(void)printLists; +-(void)markListAsDone; +-(void)removeList; +-(void)showCompletedLists; +-(void)showIncompletedLists; @end -@implementation Item +@implementation TaskManager +{ + //char input; + NSMutableArray* _lists; + +} +-(void)addList{ + NSLog(@"name your list!"); + + + int i=0; + if (_lists==nil) { //<--------------------------conditional exists becuase the 1st time addlist is called it wont be able to return one + _lists = [[NSMutableArray alloc] init]; + } + + List* myList=[[List alloc] init];//<-----------called the "List" class to instantiate a list + char myListName[200]; + scanf("%s",myListName); + NSString *newListName = [NSString stringWithUTF8String:myListName]; + [myList setListName: newListName]; + [myList setlistIsDone:NO]; + [_lists addObject:myList];//<-------------------------------------The myList array gets stored into _listItems + + NSLog(@"set your items in your list!"); + + while(true) + + { + + char itemName[256]; + scanf("%s",itemName); + NSString *myItem = [NSString stringWithUTF8String:itemName]; //<-------scanf cant accept an NSString, so we convert it into "myItem." + if([myItem isEqual:@"nil"]) + { + break; + } + [myList addItemWithName:myItem withPriority:1]; //<---calls the "myItem" method in the Item class and defaults the priority to 1. + + i++; + + } + + NSLog(@"Good Job!"); + +} + +-(NSMutableArray*)getLists{ + return _lists; +} + +- (void)printLists{ + for(int counter=0; counter<[_lists count]; counter++){ + NSLog(@"%@", [_lists[counter] listName]); + + NSLog(@"Which List do you want to access?"); + + char doneList[200]; + scanf("%s",doneList); + NSString *markedName = [NSString stringWithUTF8String:doneList]; + for(int counter=0; counter< [_lists count]; counter++){ + if ([[_lists[counter] listName] isEqualToString: markedName]) { + [_lists[counter] manageList]; + } + } + + + + } +} + +-(void)markListAsDone { + NSLog(@"Enter List name you want to mark as Done!"); + char doneList[200]; + scanf("%s",doneList); + NSString *markedName = [NSString stringWithUTF8String:doneList]; + for(int counter=0; counter< [_lists count]; counter++){ + if ([[_lists[counter] listName] isEqualToString: markedName]) { + [_lists[counter] setlistIsDone:YES]; + } + } +} + +-(void)removeList{ + NSLog(@"Enter List you want to remove!"); + char doneList[200]; + scanf("%s",doneList); + NSString *markedName = [NSString stringWithUTF8String:doneList]; + for(int counter=0; counter< [_lists count]; counter++){ + if ([[_lists[counter] listName] isEqualToString: markedName]){ + [ _lists removeObjectAtIndex:counter]; + counter--; + } + } +} + +-(void)showCompletedLists{ + for(int counter=0;counter<[_lists count]; counter++) + { + if([_lists[counter] listIsDone] == YES) { + NSLog(@"%@\n", [_lists[counter] listName]); + + } + + } +} + + +-(void)showIncompletedLists{ + for(int counter=0;counter<[_lists count]; counter++) + { + if([_lists[counter] listIsDone] == NO) { + NSLog(@"%@", [_lists[counter] listName]); + + } + + } +} @end -//// + + + + + + + + + +//-------------------------------------------------------------------------------------------------------------------------------------------// int main(int argc, const char * argv[]) { @autoreleasepool { - // insert code here... - NSLog(@"Hello, World!"); - + TaskManager* myFirstApp = [[TaskManager alloc] init]; + + while (true) { + + + + // NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; + // NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + // + // NSInteger input=[inputLine integerValue]; + + + + NSLog(@"What would you like to do?\n press: \n 1 to add a list\n 2 to remove a list\n 3 to mark a list as done\n 4 to show completed lists\n 5 to show incompleted lists\n 6 to show all lists"); + + + NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; + NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + NSInteger input=[inputLine integerValue]; + + switch (input) { + case 0: + NSLog(@"NICE JOB ORGANIZING YOUR LIFE!"); + break; + case 1: + [myFirstApp addList]; + break; + + case 2: + [myFirstApp removeList]; + break; + + case 3: + [myFirstApp markListAsDone]; + break; + + case 4: + [myFirstApp showCompletedLists]; + break; + + case 5: + [myFirstApp showIncompletedLists]; + break; + case 6: + [myFirstApp printLists]; + break; + default: + NSLog(@"YO you messed up ma G"); + } + + } + + + return 0; } - return 0; } + + + + + + +