Most code-efficient menu system

This is a discussion on Most code-efficient menu system within the C++ Programming forums, part of the General Programming Boards category; Hello, This is not much of a lingual question, but I figured that since its answer will have to do ...

  1. #1
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    907

    Most code-efficient menu system

    Hello,
    This is not much of a lingual question, but I figured that since its answer will have to do with how to use the language, it belongs on this board.
    I am writing a very simple checkbook register application for myself. I am writing it so that it can be compiled for any command line environment for which there is a C++ compiler. So the user interface will be very simple.
    The problem I'm having is figuring out how I'm going to implement the menu system. In the past, I would have done the whole thing explicity, creating a sort of logical tree of menus, separated into functional units. That, however, soon becomes messy. I thought, perhaps, of connecting each menu option with a function object, and doing it abstractly that way, but it seems excessive. Let me show you an example of what kind of interface I'll be making, and you tell me how you might go about implementing it most efficiently. Thanks in advance.
    Here, the user input is set aside by a colon (for our sake).
    Code:
    --Version 0.0.0--
    --enter "back" at any enumerated selection to go to previous selection--
    1. New file
    2. Load file
    3. Save and Exit
    4. Just Exit
     : 2
    Please enter file path
     : my_accounts.dat
    Load successful
    --Accounts--
    1. My Crazy Checking!
    2. Savings
    3. Campus-Edge
    4. Money Market
    5. New Account
     : 1
    --------My Crazy Checking--------
    6/7/07   ATM         -50.00       250.00
    6/8/07   Grad Money  100.00       350.00
    6/15/07  Alimony     -10000.00  -9650.00
    1. Transaction (-withdraw, +deposit)
    2. View whole register
    3. Print register (implementation dependent... uh oh...)
    4. Delete account
     : 1
    How much?
     : 9650.00
    Why?
     : Court Settlement
    --------My Crazy Checking--------
    6/8/07   Grad Money       100.00    350.00
    6/15/07  Alimony          -10000.00 -9650.00
    6/25/07  Court Settlement 9650.00    0.00
    1. Transaction (-withdraw, +deposit)
    2. View whole register
    3. Print register (implementation dependent... uh oh...)
    4. Delete account
     : back
    --Accounts--
    1. My Crazy Checking!
    2. Savings
    3. Campus-Edge
    4. Money Market
    5. New Account
     : back
    1. New file
    2. Load file
    3. Save and Exit
    4. Just Exit
     : 3
    Save to my_accounts.dat successful.
    *edit*
    *maybe just the calling stack is the right thing*
    Code:
    file_menu()
        input loop/switch
             load_file -->  accounts_menu()
                                input loop/switch
                                       choose account --> get_acct()
                                                             input loop/switch
                                                                   back --> return
    So we end up at the accounts_menu() loop.
    Last edited by CodeMonkey; 06-24-2007 at 11:16 PM.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Best "Menu" method?
    By SSJMetroid in forum Game Programming
    Replies: 11
    Last Post: 12-07-2005, 11:05 PM
  2. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  4. Hiding System Menu
    By C4Code in forum Windows Programming
    Replies: 8
    Last Post: 10-08-2002, 10:15 AM
  5. How do I write more efficient code?
    By minesweeper in forum C++ Programming
    Replies: 4
    Last Post: 08-06-2002, 11:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21