-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes-program.lua
More file actions
69 lines (63 loc) · 1.66 KB
/
Copy pathNotes-program.lua
File metadata and controls
69 lines (63 loc) · 1.66 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
66
67
68
69
print("---------------------------------------------------------")
print("------------------Notes-program by F3v1------------------")
print("---------------------------------------------------------")
print("")
local notes = {}
local function showMenu()
print("\nNotes App")
print("1. Add a Note")
print("2. Show All Notes")
print("3. Delete a Note")
print("4. Exit")
io.write("Choose an option: ")
end
local function addNote()
io.write("Enter your note: ")
local note = io.read()
if note and note ~= "" then
table.insert(notes, note)
print("Note added successfully!")
else
print("Empty note was not added.")
end
end
local function listNotes()
if #notes == 0 then
print("No notes available.")
else
print("\nYour Notes:")
for i, note in ipairs(notes) do
print(i .. ". " .. note)
end
end
end
local function deleteNote()
listNotes()
if #notes == 0 then return end
io.write("Enter the number of the note to delete: ")
local input = io.read()
local index = tonumber(input)
if index and index >= 1 and index <= #notes then
table.remove(notes, index)
print("Note deleted successfully!")
else
print("Invalid number.")
end
end
local running = true
while running do
showMenu()
local choice = io.read()
if choice == "1" then
addNote()
elseif choice == "2" then
listNotes()
elseif choice == "3" then
deleteNote()
elseif choice == "4" then
running = false
print("Exiting Notes App. Goodbye!")
else
print("Invalid choice, please try again.")
end
end