From: Tim Romberg Date: 2010-09-12T02:37:31+09:00 Subject: Why does my program exit?! Hi I was hoping that anyone could help me with this piece of code from my program?! I have a menu with 2 submenus that you can reach from the main menu. When I start the program I want the main menu to be presented with a number of choices. My program is based on user input so naturally when you enter the program you should be able to do the choices that are presented in the menus. It worked before but now when I started adding features for it(its for an assignment for a course) now it just presents the menu and then exits the program. Can anyone help me with this. I will post the code below and hopefully someone with more programming skills than me can see the problem. Thanks! module Menus def self.getValidNumber input = gets.chomp while input > @options.size || input < 1 do puts "cant do that try again." input = gets.chomp end number = input.to_f if (number <= 0) puts "cant state a negative value." getValidPositiveNumber end return number end def self.get_valid_input(options) input = gets.chomp while (!options.include?(input) && !options.include?(input.to_i)) puts "No good, you have to choose a value between " + valid_options.inspect input = gets.chomp end return input end class Menu attr_reader :options # Pass in array of options def initialize(options) @options = options end def main_menu puts "---------------------------" puts " Main Menu" @options.each_with_index do |item, i| puts " #{i+1}. #{item}" end puts puts "What do you want to do?" end def self.make_choice(choice) # chooses something from the menu based on the choice case choice when 1 check_in when 2 check_out when 3 puts $in_menu = lists_menu when 4 puts $in_menu = economy_menu when 5 puts "You are now leaving the camping, welcome back!" exit end end def lists_menu puts "---------------------------" puts " List Menu" @options.each_with_index do |item, i| puts " #{i+1}. #{item}" end puts puts "What do you want to do?" end def self.make_choice(choice) case choice when 1 puts $camping when 2 puts $camping.history.all_guests when 0 $in_menu = main.menu end end def economy_menu puts "---------------------------" puts " List Menu" @options.each_with_index do |item, i| puts " #{i+1}. #{item}" end puts puts "What do you want to do?" end def self.make_choice(choice) case choice when 1 $camping.economy.printCosts when 2 $camping.economy.enterNewPrices when 3 puts $camping.history puts $camping.economy when 0 $in_menu = MAIN_MENU end end m = Menus::Menu.new ["Checkin", "Checkout","Lists","Economy","Exit"] m.main_menu if Menus == 3 then m = Menus::Menu.new ["List current guests","List all guests","back to main menu"] m.lists_menu elsif Menus == 4 then m = Menus::Menu.new ["Price list","Edit price list","back to main menu"] m.economy_menu end end end -- Posted via http://www.ruby-forum.com/.