• Home
  • About
    • Chaeeun Gim photo

      Chaeeun Gim

      Game Development.

    • Learn More
    • Email
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • Posts
    • All Posts
    • All Tags
  • Projects
  • Concept Arts

Simple Menu

21 Mar 2019

Reading time ~1 minute

In this task you combine control flow with modularization to create the basis of a menu system for a text-based (terminal based) Music player.

Simple Menu

purpose

Learn to combine control flow and modularisation.

#### Instruction ■ A repeat-until loop with the following:
■ Display the sub-menu options and prompt the user to select one
■ Read in the user selection and then use a case statement to
call a procedure that corresponds to the selection (or leave the loop if they chose exit)
■ The called procedure should display a message to user about the option.
You do not need to implement the procedure at this stage,
just leave it as a ‘stub’ that displays a message.


▼ Create the function for displaying main menu.

def main()
  finished = false
  begin
    puts 'Main Menu: Enter your selection: '
    puts '1 To Enter or Update Album'
    puts '2 To Play existing Album'
    puts '3 Exit'
    choice = read_integer_in_range("Please enter your choice:", 1,3)
    case choice
    when 1
      puts 'You selected for looking for maintain albums'
      maintain_albums()
    when 2
      play_existing_album()
    when 3
      puts "good bye!"
      finished == true
    else
      puts 'Please select again'
    
    end until finished == true
  end
end

main()


codefunction Share Tweet +1