Ruby
3 credits
BankAccount class is used | 10 |
Open Accounts option opens accounts | 10 |
Open account option will not allow more than 5 accounts | 10 |
View accounts option shows list of open accounts | 10 |
Deposit option allows deposits of a chosen amount into a selected account. | 10 |
Withdraw option allows withdrawal of a chosen amount from a selected account. | 10 |
Exit option terminates program | 10 |
Program loops and does not stop until Exit is selected | 10 |
Program display menu of choices for the user | 10 |
Opened accounts are stored in an array | 10 |
Total | 100 pts |
To work with Ruby's control structures
For this lab you will be using the BankAccount class we created in class to write a small interactive Ruby program to simulate the workings of the worlds smallest and simplest bank.
Your task is to create a Ruby program that displays a menu to the user with the following options: Open Account, List Accounts, Make Deposit, Make Withdraw, and Exit.
When the program first starts it should contain no BankAccount instances but when the user chooses option 1 Open Account the program should create a new BankAccount instance and store it in an array. Every time the user chooses this option a new account should be created and added to the array but the user should not be allowed to open more than 5 accounts. The program does not need to be persistent in that each time the program is restarted it will start with no accounts.
When the user chooses option 2 View Accounts they should be shown a list of all existing accounts including the account number, the balance, and the name on the account.
When the user chooses option 3 Make Deposit the user should be prompted for both the amount to deposit and which account they want to deposit to which will mean that the user needs to be shown a list of available accounts to choose from. When the user has entered an amount and selected an account the deposit should be made.
When the user chooses option 4 Make Withdraw the user should be again prompted for the amount and which account to withdraw from making this option almost identical to the Deposit options except that a withdraw will be performed instead of the deposit.
Finally, when the user chooses option 5 Exit the program should end. Until the user chooses option 5 Exit the program should continue to loop, taking the user back to the main menu after any option has been selected and completed.