Week 19
Source Code
local myName = ""
print("Name: " .. myName)
-- define main function
function main()
local done = false
local choice = nil
while not done do
print("Menu")
print("E1 - Example 1")
print("Q - Quit")
io.write("Choice: ")
choice = io.read()
if choice == "E1" then
-- call Example 1 Function
example1()
elseif choice == "E2" then
-- call Example 2 Function
example2()
elseif choice == "E3" then
-- call Example 3 Function
example3()
elseif choice == "Q" then
done = true
else
print("Invalid Choice")
end
end
end
-- define Example 1 Function
function example1()
-- declare an array of friends
-- print the elements one by one
-- print friends v1
-- print friends v2
-- assign value to first friend
-- assign value to last friend
-- print friends
end
-- define Example 2 Function
function example2()
-- create an empty fruits array
-- add a fruit to the end of the array
-- add a fruit to the end of the array
-- add a fruit to the beginning of the array
-- for in loop
-- delete a fruit
end
-- define Example 3 Function
function example3()
end
-- call main function
main()
Last updated