我真的是Ruby中的新手。
所以我确实在循环中制作了一个菜单,它将我发送到" start.menu_one",但是我可以在" def菜单_one"中进行另一个循环,可以将我发送到" def Menu_three"
问题是我无法运行代码吗?你们中的任何一个都知道问题是什么,因为我找不到。
file = File.new(".txt", "a")
class Start
def menu_one
while (select !=2)
puts "Press 1 to make a new test"
puts "Press 2 to search after test results"
if (select == 1)
start.menu_three
break
elsif (select == 2) # its here the problem is?
end
def menu_two
puts "Press 1 to see the overview of the tests"
end
end
def menu_three
puts "hej"
end
end
start = Start.new
require 'io/console'
select = 0
puts "Welcome to the multiple choice test"
while (select !=3)
puts "Press 1 to login as admin"
puts "n"
puts "Press 2 to login as student"
puts "n"
puts "Press 3 to exit "
puts "n"
select = STDIN.getch.to_i
if (select == 1)
start.menu_one
break
elsif (select == 2)
start.menu_two
break
elsif (select == 3)
puts "You have now exited the program"
abort
end
end
end
class Start
def menu_one
while (select !=2)
puts "Press 1 to make a new test"
puts "Press 2 to search after test results"
if (select == 1)
start.menu_three
break
elsif (select == 2) # its here the problem is?
end
def menu_two
puts "Press 1 to see the overview of the tests"
end
end
def menu_three
puts "hej"
end
end
start = Start.new
require 'io/console'
select = 0
puts "Welcome to the multiple choice test"
while (select !=3)
puts "Press 1 to login as admin"
puts "n"
puts "Press 2 to login as student"
puts "n"
puts "Press 3 to exit "
puts "n"
select = STDIN.getch.to_i
if (select == 1)
start.menu_one
break
elsif (select == 2)
start.menu_two
break
elsif (select == 3)
puts "You have now exited the program"
abort
end
end
end