-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (44 loc) · 1017 Bytes
/
main.go
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
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
todoList := TodoList{Items: []*TodoItem{}}
scanner := bufio.NewScanner(os.Stdin)
for {
fmt.Println("1. Add Item")
fmt.Println("2. Print List")
fmt.Println("3. Complete Item")
fmt.Println("4. Delete Item")
fmt.Println("5. Quit")
fmt.Print("Choose an option: ")
scanner.Scan()
option := scanner.Text()
switch option {
case "1":
fmt.Print("Enter Todo item title: ")
scanner.Scan()
title := scanner.Text()
todoList.AddItem(title)
case "2":
todoList.PrintList()
case "3":
fmt.Print("Enter ID of Todo item to complete: ")
scanner.Scan()
id, _ := strconv.Atoi(scanner.Text())
todoList.CompleteItem(id)
case "4":
fmt.Print("Enter ID of Todo item to delete: ")
scanner.Scan()
id, _ := strconv.Atoi(scanner.Text())
todoList.DeleteItem(id)
case "5":
return
default:
fmt.Println("Invalid option. Please choose again.")
}
}
}