diff --git a/Todo-Challenge/Todo-Challenge/Program.cs b/Todo-Challenge/Todo-Challenge/Program.cs index 3751555..d0a3f50 100644 --- a/Todo-Challenge/Todo-Challenge/Program.cs +++ b/Todo-Challenge/Todo-Challenge/Program.cs @@ -1,2 +1,83 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using System; +using System.Collections.Generic; + +namespace ToDoListApp +{ + class Program + { + static void Main(string[] args) + { + List todoList = new List(); + + Console.WriteLine("Welcome to the To-Do List App!"); + while (true) + { + Console.WriteLine("\nPlease choose an action:"); + Console.WriteLine("1. Add todo item"); + Console.WriteLine("2. Complete todo item"); + Console.WriteLine("3. See all todo items"); + Console.WriteLine("4. Delete todo item"); + Console.WriteLine("5. Exit"); + + if (int.TryParse(Console.ReadLine(), out int choice)) + { + switch (choice) + { + case 1: // Add a todo item + Console.Write("\nEnter todo: \n"); + string description = Console.ReadLine(); + ToDoItem newItem = new(description); + todoList.Add(newItem); + Console.WriteLine($"\nTodo item: '{description}' added.\n"); + break; + + case 2: // Complete specific todo items + Console.Write("\nEnter todo number to complete: \n"); + if (int.TryParse(Console.ReadLine(), out int todoIndex) && todoIndex > 0 && todoIndex <= todoList.Count) + { + todoList[todoIndex - 1].IsCompleted = true; + Console.WriteLine($"\nTodo item '{todoList[todoIndex - 1].Description}' completed.\n"); + } + else + { + Console.WriteLine("\nInvalid todo number.\n"); + } + break; + + case 3: // View all todo items + if (todoList.Count == 0) + { + Console.WriteLine("\nYour todo list is empty.\n"); + } + else + { + Console.WriteLine("\nYour To-Do List:"); + for (int i = 0; i < todoList.Count; i++) + { + string status = todoList[i].IsCompleted ? "[X]" : "[ ]"; + Console.WriteLine($"{i + 1}. {status} {todoList[i].Description}"); + } + } + break; + + case 4: // Delete a todo item + Console.Write("\nEnter todo number to delete: \n"); + if (int.TryParse(Console.ReadLine(), out int todoremoveIndex) && todoremoveIndex > 0 && todoremoveIndex <= todoList.Count) + { + todoList.RemoveAt(todoremoveIndex - 1); + Console.WriteLine($"\nTodo number {todoremoveIndex} deleted.\n"); + } + else + { + Console.WriteLine("\nInvalid todo number.\n"); + } + break; + + case 5: + return; + } + } + } + } + } +} \ No newline at end of file diff --git a/Todo-Challenge/Todo-Challenge/ToDoItemClass.cs b/Todo-Challenge/Todo-Challenge/ToDoItemClass.cs new file mode 100644 index 0000000..89813ae --- /dev/null +++ b/Todo-Challenge/Todo-Challenge/ToDoItemClass.cs @@ -0,0 +1,14 @@ +namespace ToDoListApp +{ + public class ToDoItem + { + public string Description { get; set; } + public bool IsCompleted { get; set; } + + public ToDoItem(string description) + { + Description = description; + IsCompleted = false; + } + } +} \ No newline at end of file