From fc21d9ace1239bbd13b45cd44134d17721bd0820 Mon Sep 17 00:00:00 2001 From: Artur Lane Date: Sat, 27 Jun 2015 14:19:28 -0400 Subject: [PATCH 1/3] 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 483cfe9d355d1005ae551bb4c87e013f29d50b81 Mon Sep 17 00:00:00 2001 From: Artur Lane Date: Sat, 27 Jun 2015 17:22:21 -0400 Subject: [PATCH 2/3] Second commit --- TodoList/TodoList/main.m | 103 +++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 27 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 62ee019..66c7b71 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -8,62 +8,111 @@ #import +@interface ToDoListApp : NSObject -@interface ToDoList: NSObject +@property NSMutableArray *_listMenu; -@property NSMutableArray *_taskArray; +@end +@implementation ToDoListApp { + +} --(void)listItems:(NSMutableArray *)listItems; --(NSMutableArray *)listItems; +-(void)addList:(NSMutableArray *)addList; {// adds list to ToDoListApp +} +-(void)removeList:(NSMutableArray *)removeList; {// removes list from ToDoListApp +} -//-(void)addItems:(NSMutableArray *)addItems; -//-(NSString *)addItems; -// -//-(void)removeItems:(NSMutableArray *)removeItems; -////removeItems; -// -//-(void)markItemDone:(NSMutableArray *)markItemDone; -//-(NSMutableArray *)listItems; -// -//-(void)listCompletedItem:(NSMutableArray *)listCompletedItem; -//-(NSMutableArray *)listCompletedItem; +-(void)completedLists:(NSMutableArray *)completedList; {// prints completed list to ToDoListApp +} + +-(void) printList:(NSMutableArray *)printList; {// adds list to ToDoListApp +} @end -@implementation ToDoList --(void)listItems:(NSMutableArray *)listItems { +@interface list: NSObject + +@property NSMutableArray *_listItem; +@property NSString *_name; + +@end + + +@implementation list { - for(int counter=0; counter<=[listItems count]; counter++){ - NSLog(@"%c", listItems[counter].name); - + + for(int i=0;i<=[listItem count];i++) + { + listItem[i]= [[item alloc] init]; + scanf("%@",&ListItem[i]) } + } -@end -//////////////////// +-(void)addItem:(NSMutableArray *)addList { + -@interface Item: NSObject + char word; + scanf("%s", &word); + NSString *_newItem = [NSString stringWithUTF8String:&word]; + + [__listItem addObject:_newItem]; + + +} + +-(void)removeItem:(NSMutableArray *)removeListItem; { +} + +-(void)listCompletedItems:(NSMutableArray *)completedListItem; { +} + +-(void)markItemDone :(NSMutableArray *)printListItem; { +} + +-(void)priorityValueForItem :(NSMutableArray *)priorityValueItem; { + + for (int counter=0; counter<=[__listItem count]; counter++) { + scanf("%d",__listItem[counter]); + + } + + +} +-(void)printAllItems:(NSMutableArray *)entirelist; { + + for (int counter=0; counter<=[__listItem count]; counter++) { + NSLog(@"%@",__listItem[counter]); + } +} @end -@implementation Item +@interface item: NSObject +@property int priority; +@property NSString *task; @end -//// +@implementation item { + + +} +@end + + int main(int argc, const char * argv[]) { @autoreleasepool { - // insert code here... - NSLog(@"Hello, World!"); + From 7ed83932ec307067841efc8079a056d9e352a109 Mon Sep 17 00:00:00 2001 From: Artur Lane Date: Wed, 1 Jul 2015 22:31:13 -0400 Subject: [PATCH 3/3] final project --- TodoList/TodoList/main.m | 359 +++++++++++++++++++++++++++++++++------ 1 file changed, 310 insertions(+), 49 deletions(-) diff --git a/TodoList/TodoList/main.m b/TodoList/TodoList/main.m index 66c7b71..367a2b6 100644 --- a/TodoList/TodoList/main.m +++ b/TodoList/TodoList/main.m @@ -1,122 +1,383 @@ // // 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 ToDoListApp : NSObject +@interface Item : NSObject -@property NSMutableArray *_listMenu; +-(void)setPriorityValue:(NSInteger)priorityValue; +- (NSInteger)priorityValue; + + +-(void)setTask:(NSString *)task; +- (NSString*) task; + +-(void)setIsDone:(BOOL)isDone; +-(BOOL)isDone; //<-------property will inform us whether task is completed. @end -@implementation ToDoListApp { - +@implementation Item { + NSInteger _priorityValue; + NSString* _task; + BOOL _isDone; } --(void)addList:(NSMutableArray *)addList; {// adds list to ToDoListApp +-(void)setPriorityValue:(NSInteger)priorityValue{ + _priorityValue=priorityValue; } --(void)removeList:(NSMutableArray *)removeList; {// removes list from ToDoListApp +-(NSInteger)priorityValue{ + return _priorityValue; } - --(void)completedLists:(NSMutableArray *)completedList; {// prints completed list to ToDoListApp +-(void)setTask:(NSString *)task{ + _task=task; } - --(void) printList:(NSMutableArray *)printList; {// adds list to ToDoListApp +-(NSString*)task{ + return _task; } +-(void)setIsDone:(BOOL)isDone{ + _isDone=isDone; +} +-(BOOL)isDone{ + return _isDone; +} @end +//-------------------------------------------------------------------------------------------------------------------------------------// + +//-------------------------------------------CLASS THAT DEFINES A LIST----------------------------------------------------------------// +@interface List : NSObject -@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; -@property NSMutableArray *_listItem; -@property NSString *_name; @end +@implementation List{ + NSString* _listName; + NSMutableArray* _listItems; + BOOL listIsDone; +} -@implementation list { +-(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 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"); + switch (input) { + case 0: + NSLog(@"NICE JOB ORGANIZING THIS LIST"); + break; + case 1: + [self printListItems]; + case 2: + [self addItem]; + + case 3: + [self listIsDone]; + case 4: + [self removeItemFromList]; + + case 5: + // [self showIncompletedLists]; + + break; + + default: + NSLog(@"YO you messed up ma G"); + } + + } - for(int i=0;i<=[listItem count];i++) - { - listItem[i]= [[item alloc] init]; - scanf("%@",&ListItem[i]) - } } --(void)addItem:(NSMutableArray *)addList { - - char word; - scanf("%s", &word); - NSString *_newItem = [NSString stringWithUTF8String:&word]; - - [__listItem addObject:_newItem]; - +-(void)addItemWithName:(NSString *)name withPriority:(NSInteger)priority{ } --(void)removeItem:(NSMutableArray *)removeListItem; { + +-(void)setListName:(NSString *)listName{ + _listName=listName; } --(void)listCompletedItems:(NSMutableArray *)completedListItem; { +-(NSString*)listName{ + return _listName; } --(void)markItemDone :(NSMutableArray *)printListItem; { +-(void)printListItems{ + for(int count=0;count<[_listItems count]; count++) + { + NSLog(@"%@, %ld", [_listItems[count] task],[_listItems[count] priorityValue]); + } } --(void)priorityValueForItem :(NSMutableArray *)priorityValueItem; { +-(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!" + } - for (int counter=0; counter<=[__listItem count]; counter++) { - scanf("%d",__listItem[counter]); - + 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)printAllItems:(NSMutableArray *)entirelist; { + +-(void)removeItemFromList{ - for (int counter=0; counter<=[__listItem count]; counter++) { - NSLog(@"%@",__listItem[counter]); - } + 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 +//---------------------------------------------------------------------------------------------------------------------------------------------// -@property int priority; -@property NSString *task; +//------------------------------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* _listItems; + +} +-(void)addList{ + NSLog(@"name your list!"); + int i=0; + if (_listItems==nil) { //<--------------------------conditional exists becuase the 1st time addlist is called it wont be able to return one + _listItems = [[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]; + [_listItems 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 _listItems; +} + +- (void)printLists{ + for(int counter=0; counter<[_listItems count]; counter++){ + NSLog(@"%@", [_listItems[counter] listName]); + } +} + +-(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< [_listItems count]; counter++){ + if ([[_listItems[counter] name] isEqualToString: markedName]) { + [_listItems[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< [_listItems count]; counter++){ + if ([[_listItems[counter] name] isEqualToString: markedName]){ + [ _listItems removeObjectAtIndex:counter]; + counter--; + } + } +} + +-(void)showCompletedLists{ + for(int counter=0;counter<[_listItems count]; counter++) + { + if([_listItems[counter] listIsDone] == YES) { + NSLog(@"%@", [_listItems[counter] name]); + + } + + } } + + +-(void)showIncompletedLists{ + for(int counter=0;counter<[_listItems count]; counter++) + { + if([_listItems[counter] listIsDone] == NO) { + NSLog(@"%@", [_listItems[counter] name]); + + } + + } +} + + @end + + + + + + + + +//-------------------------------------------------------------------------------------------------------------------------------------------// int main(int argc, const char * argv[]) { @autoreleasepool { - - + + while (true) { + + NSLog(@"Input stuff bro!"); + + NSFileHandle *standardInput = [NSFileHandle fileHandleWithStandardInput]; + NSString *inputLine = [[[NSString alloc] initWithData:standardInput.availableData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + NSInteger input=[inputLine integerValue]; + + + TaskManager* myFirstApp = [[TaskManager alloc] init]; + NSLog(@"What would you like to do?\n PRESS 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"); + switch (input) { + case 0: + NSLog(@"NICE JOB ORGANIZING YOUR LIFE!"); + break; + case 1: + [myFirstApp addList]; + case 2: + [myFirstApp removeList]; + case 3: + [myFirstApp markListAsDone]; + case 4: + [myFirstApp showCompletedLists]; + case 5: + [myFirstApp showIncompletedLists]; + + break; + + default: + NSLog(@"YO you messed up ma G"); + } + + } + + + return 0; } - return 0; } + +