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.