@@ -31,6 +31,8 @@ local LastNames = {
3131 " Jackson"
3232}
3333
34+ local menu = {" print ns" ," add custom n" ," add f n" ," add l n" ," clear f ns" ," clear l ns" ," delete f n" ," delete l n" ," stop" }
35+
3436local busy = false
3537
3638local function PrintFirstName (value )
4547local function PrintLastName (value )
4648 for count = 1 , value do
4749 if # LastNames ~= 0 then
48- print (LastNames [math.random (1 ,# LastNames )])
50+ print (LastNames [math.random (1 ,# LastNames )])
4951 else print (" " )
5052 end
5153 end
@@ -88,10 +90,17 @@ function is_numeric(x)
8890 return false
8991end
9092
91- local function DeleteN (tab )
92- for i ,v in ipairs (tab ) do
93+ local function printContent (tab )
94+ for i ,v in ipairs (tab ) do
9395 print (i ,v )
96+ print ()
9497 end
98+ end
99+
100+ local function DeleteN (tab )
101+ for i ,v in ipairs (tab ) do
102+ print (i ,v )
103+ end
95104 io.write (" Which name would you like to delete? Enter Number" )
96105 local choice = io.read ()
97106 print ()
@@ -100,18 +109,20 @@ local function DeleteN(tab)
100109 else print (" not valid number" )
101110 end
102111end
103-
112+
104113while not busy do
105114busy = true
106115print ()
107116io.write (" What do you want to do?" )
108- print ()
117+ print ()
118+ printContent (menu )
109119local choice = io.read ()
110120print ()
111121 if choice == " print ns" then
112122 io.write (" Enter Number" )
113123 print ()
114- value = io.read ()
124+ value = io.read ()
125+ print ()
115126 PrintNames (value )
116127 elseif choice == " add custom n" then
117128 CustomName ()
@@ -121,7 +132,7 @@ print()
121132 InsertLName ()
122133 elseif choice == " stop" then
123134 break
124- elseif choice == " clear f n " then
135+ elseif choice == " clear f ns " then
125136 FirstNames = {}
126137 elseif choice == " clear l ns" then
127138 LastNames = {}
@@ -132,4 +143,4 @@ print()
132143 else print (" Not Valid Command" )
133144 end
134145 busy = false
135- end
146+ end
0 commit comments