-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu_option.cpp
More file actions
29 lines (25 loc) · 881 Bytes
/
menu_option.cpp
File metadata and controls
29 lines (25 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include <limits> // For std::numeric_limits *Important*
#include"menu_option.h"
using namespace std;
namespace banking_system
{
// BankMenuOption::BankMenuOption() {};
MenuOption BankMenuOption::ReadUserInput()
{
int sel_option;
cout << "Available Operations:\n"
<< "1. Withdraw\n"
<< "2. Deposit\n"
<< "3. Print\n"
<< "4. Quit\n";
cout << "Select Option: ";
while (!(cin >> sel_option) || cin.peek() != '\n') {
cout << "Invalid input.\n";
cout << "Select Option: ";
cin.clear(); // Clear error flags
cin.ignore(numeric_limits<streamsize>::max(), '\n'); // Discard incorrect input
}
return static_cast<banking_system::MenuOption>(sel_option);
};
}