Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions TodoList/TodoList.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
29DC02311B44D98300C3F5B7 /* Item.m in Sources */ = {isa = PBXBuildFile; fileRef = 29DC022C1B44D98300C3F5B7 /* Item.m */; };
29DC02321B44D98300C3F5B7 /* List.m in Sources */ = {isa = PBXBuildFile; fileRef = 29DC022E1B44D98300C3F5B7 /* List.m */; };
29DC02331B44D98300C3F5B7 /* ListManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 29DC02301B44D98300C3F5B7 /* ListManager.m */; };
8D9789F71B3C9A7F007CF4CF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D9789F61B3C9A7F007CF4CF /* main.m */; };
/* End PBXBuildFile section */

Expand All @@ -23,6 +26,12 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
29DC022B1B44D98300C3F5B7 /* Item.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Item.h; sourceTree = "<group>"; };
29DC022C1B44D98300C3F5B7 /* Item.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Item.m; sourceTree = "<group>"; };
29DC022D1B44D98300C3F5B7 /* List.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = List.h; sourceTree = "<group>"; };
29DC022E1B44D98300C3F5B7 /* List.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = List.m; sourceTree = "<group>"; };
29DC022F1B44D98300C3F5B7 /* ListManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListManager.h; sourceTree = "<group>"; };
29DC02301B44D98300C3F5B7 /* ListManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListManager.m; sourceTree = "<group>"; };
8D9789F31B3C9A7F007CF4CF /* TodoList */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TodoList; sourceTree = BUILT_PRODUCTS_DIR; };
8D9789F61B3C9A7F007CF4CF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -58,6 +67,12 @@
isa = PBXGroup;
children = (
8D9789F61B3C9A7F007CF4CF /* main.m */,
29DC022B1B44D98300C3F5B7 /* Item.h */,
29DC022C1B44D98300C3F5B7 /* Item.m */,
29DC022D1B44D98300C3F5B7 /* List.h */,
29DC022E1B44D98300C3F5B7 /* List.m */,
29DC022F1B44D98300C3F5B7 /* ListManager.h */,
29DC02301B44D98300C3F5B7 /* ListManager.m */,
);
path = TodoList;
sourceTree = "<group>";
Expand Down Expand Up @@ -118,7 +133,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
29DC02321B44D98300C3F5B7 /* List.m in Sources */,
29DC02311B44D98300C3F5B7 /* Item.m in Sources */,
8D9789F71B3C9A7F007CF4CF /* main.m in Sources */,
29DC02331B44D98300C3F5B7 /* ListManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -235,6 +253,7 @@
8D9789FC1B3C9A7F007CF4CF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
27 changes: 27 additions & 0 deletions TodoList/TodoList/Item.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Item.h
// toDoListFromScratchZoufAndAyuna
//
// Created by Ayuna Vogel on 6/30/15.
// Copyright (c) 2015 Ayuna Vogel. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Item.h"
#import "List.h"
#import "ListManager.h"

@class ListManager;
@class List;
@class Item;

@interface Item : NSObject
-(void) setItem: (NSString *) item;
-(void) addItemDescription;
-(void) setItemPriority: (int) itemPriority;
-(NSString*) itemName;
-(int) itemPriority;
-(BOOL) markedDone;
-(void) setMarkedDone:(BOOL)markedDone;

@end
51 changes: 51 additions & 0 deletions TodoList/TodoList/Item.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Item.m
// toDoListFromScratchZoufAndAyuna
//
// Created by Ayuna Vogel on 6/30/15.
// Copyright (c) 2015 Ayuna Vogel. All rights reserved.
//

#import "Item.h"

@implementation Item {

NSString* _itemName;
int _itemPriority;
BOOL _markedDone;
}

-(void) setItem: (NSString *) item {
_itemName = item;
}

-(void) addItemDescription {
NSLog(@"Enter task description: ");
//fgets method allows user to input more than one word ie: "finish project"
char itemInput[256];
fgets(itemInput, 256, stdin);
NSString *itemDescription = [NSString stringWithUTF8String:itemInput];
//stringWithUTF8String converts char to string
[self setItem: itemDescription];
}

-(NSString*) itemName {
return _itemName;
}

-(void) setItemPriority: (int) itemPriority {
_itemPriority = itemPriority;
}

-(int) itemPriority {
return _itemPriority;
}
-(void) setMarkedDone:(BOOL)markedDone {
_markedDone = markedDone;
}

-(BOOL) markedDone {
return _markedDone;
}

@end
30 changes: 30 additions & 0 deletions TodoList/TodoList/List.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// List.h
// toDoListFromScratchZoufAndAyuna
//
// Created by Ayuna Vogel on 6/30/15.
// Copyright (c) 2015 Ayuna Vogel. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Item.h"
#import "List.h"
#import "ListManager.h"

@class ListManager;
@class List;
@class Item;

@interface List : NSObject
-(void)setListName: (NSString *) listName;
-(NSString *) listName;
-(NSMutableArray *) itemsInList;
-(void) addItemToList: (Item *) task;
-(void) deleteItemFromList;
-(void) printAllItemsInList;
-(void) markItemDone: (Item *) task;
-(void) renameItem;
-(void) listOptions;
-(void) goBackToLists;
-(void) addListDescription;
@end
171 changes: 171 additions & 0 deletions TodoList/TodoList/List.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
//
// List.m
// toDoListFromScratchZoufAndAyuna
//
// Created by Ayuna Vogel on 6/30/15.
// Copyright (c) 2015 Ayuna Vogel. All rights reserved.
//

#import "List.h"
@class ListManager;
@class List;

@implementation List {
NSString* _listName;
NSMutableArray* _itemsInList;
}

-(void)setListName:(NSString *)listName {
_listName = listName;
}
-(NSString*) listName {
return _listName;
}
-(NSMutableArray*)itemsInList {
if (_itemsInList == nil) {
_itemsInList = [[NSMutableArray alloc] init];
}
return _itemsInList;
}

-(void) addItemToList: (Item*) task {
[_itemsInList addObject:task];
}
-(void) deleteItemFromList {
NSLog(@"Enter a number to delete task");
int j;
scanf("%d", &j);
[_itemsInList removeObjectAtIndex:j-1];
}

-(void) printAllItemsInList {
for (int i = 0; i < [_itemsInList count]; i++) {
NSString *itemName = [[_itemsInList objectAtIndex:i] itemName];
int itemPriority = [[_itemsInList objectAtIndex:i] itemPriority];
NSLog(@"%i) %@, priority %d", i+1, itemName, itemPriority);
}
}

-(void) printAllCompletedItems:(BOOL) value {
for (int i = 0; i < [_itemsInList count]; i++) {
if ([[_itemsInList objectAtIndex:i] markedDone] == value) {
NSString *itemName = [[_itemsInList objectAtIndex:i] itemName];
int itemPriority = [[_itemsInList objectAtIndex:i] itemPriority];
NSLog(@"%i %@, priority %d", i+1, itemName, itemPriority);
}
}
}

-(void) markItemDone: (Item *) task {
NSLog(@"Enter a number to mark task done");
int j;
scanf("%d", &j);
for (int i = 0; i < [_itemsInList count]; i++) {
if (i == j) {
NSString *task = [[_itemsInList objectAtIndex:j-1] itemName];
NSString *printTaskAsCompleted = [NSString stringWithFormat:@"✔︎ %i %@", i, task];
[[_itemsInList objectAtIndex:j-1] setMarkedDone:YES];
NSLog(@"%@", printTaskAsCompleted);
}
}
}

-(void) renameItem {
[self printAllItemsInList];
NSLog(@"Enter a number to edit task");
int j;
scanf("%d", &j);
fpurge(stdin);
NSLog(@"Enter new task description");
char newTaskName[256];
fgets(newTaskName, 256, stdin);
NSString *editedTaskName = [NSString stringWithUTF8String:newTaskName];
[[_itemsInList objectAtIndex:j-1] setItem:editedTaskName];
}

-(void) goBackToLists {
//if (_lists == nil) {
//allocate new object of ListManager
// }
//[[_lists objectAtIndex: i] listManagerMenuOptions];
// int j;
// scanf("%d", &j);
// for (int i = 0; i < [_lists count]; i++) {
// if (j == 8) {
// [[_lists objectAtIndex:i] listManagerMenuOptions];
// }
// }
}

-(void) addListDescription {
NSLog(@"Enter list description: ");
char listDescriptionInput[256];
fgets(listDescriptionInput, 256, stdin);
NSString *listDescription = [NSString stringWithUTF8String:listDescriptionInput];
//stringWithUTF8String converts char to string
[self setListName:listDescription];
}

-(void) listOptions {
int i;
BOOL runListOptionsMenu = true;
while (runListOptionsMenu) {

NSArray *listOptions = [[NSArray alloc] initWithObjects:@"1 - Display all tasks", @"2 - Add new task", @"3 - Edit task", @"4 - Delete task", @"5 - Mark task done", @"6 - List all active tasks", @"7 - List completed tasks", @"8 - Go back to Lists Menu", @"0 - Quit", nil];

NSLog(@"%@", listOptions);
scanf("%d", &i);
fpurge(stdin);

if (i == 1) {
//display all items in the selected list
[self printAllItemsInList];
}
else if (i == 2) {
//add new item
Item *newToDoItem = [[Item alloc]init];
[newToDoItem addItemDescription];
[newToDoItem itemName];
[self addItemToList:newToDoItem];
}
else if (i == 3) {
//rename item
[self renameItem];
}
else if (i == 4) {
//delete item
[self printAllItemsInList];
[self deleteItemFromList];
NSLog(@"Deleted");
}
else if (i == 5) {
//mark task done
[self printAllItemsInList];
NSLog(@"Enter a task number to mark it completed");
int i;
scanf("%d", &i);
//[self markItemDone];
}
else if (i == 6) {
[self printAllCompletedItems:NO];
}
else if (i == 7) {
//print all items in list, versions: either excluding marked done items, or print all incl marked done items with a check sign
[self printAllItemsInList];
}
else if (i == 8) {
[self goBackToLists];
}
else if (i == 0) {
NSLog(@"It was good to see you! Bye!");
break;
}
else {
NSLog(@"Bummer! Try again?");
}
}
}


@end

25 changes: 25 additions & 0 deletions TodoList/TodoList/ListManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// ListManager.h
// toDoListFromScratchZoufAndAyuna
//
// Created by Ayuna Vogel on 6/30/15.
// Copyright (c) 2015 Ayuna Vogel. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Item.h"
#import "List.h"
#import "ListManager.h"

@class ListManager;
@class List;
@class Item;

@interface ListManager : NSObject
-(NSMutableArray*) getLists;
-(void) addListToListManager: (List*) list;
-(void) renameList;
-(void) deleteListFromListManager;
-(void) printLists;
-(void) listManagerMenuOptions;
@end
Loading