Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
65 lines (58 loc) · 1.64 KB
/
Copy pathProgram.cs
File metadata and controls
65 lines (58 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using TodoListProject;
namespace ExtraLektionEtt
{
class Program
{
static void Main(string[] args)
{
TodoList todoList = new();
while (true)
{
string input = Console.ReadLine();
if (input == "a")
{
AddTodoItems(todoList);
}
else if (input == "t")
{
ToggleTodoItems(todoList);
}
else if (input == "l")
{
ListTodoItems(todoList);
}
else if (input == "r")
{
todoList.RemoveTodoItem(1);
}
else if (input == "q")
{
Environment.Exit(0);
}
}
}
private static void ListTodoItems(TodoList todoList)
{
foreach (TodoItem item in todoList.GetAllTodoItems())
{
int index = todoList.GetAllTodoItems().IndexOf(item);
Console.WriteLine($"{index}. {item.IsDone} - {item.label}");
}
}
private static void ToggleTodoItems(TodoList todoList)
{
foreach (TodoItem item in todoList.GetAllTodoItems())
{
item.ToggleIsDone();
}
}
private static void AddTodoItems(TodoList todoList)
{
TodoItem todoItem = new();
todoItem.label = "Unnamed";
todoList.AddTodoItem(todoItem);
}
}
}