-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.cpp
More file actions
35 lines (34 loc) · 1.12 KB
/
Copy pathMenu.cpp
File metadata and controls
35 lines (34 loc) · 1.12 KB
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
30
31
32
33
34
35
#include "Menu.h"
#include <iostream>
using namespace std;
void Menu::show(){
cout << "=============================\n";
cout << " CHÀO MỪNG ĐẾN NGÂN HÀNG\n";
cout << "=============================\n";
cout << "1. Tạo tài khoản mới\n";
cout << "2. Xem danh sách tài khoản\n";
cout << "3. Chỉnh sửa thông tin\n";
cout << "4. Giao dịch (Gửi/Rút tiền)\n";
cout << "5. Xóa tài khoản\n";
cout << "6. Xem chi tiết tài khoản\n";
cout << "0. Thoát\n";
cout << "-----------------------------\n";
}
int Menu::getChoice() {
int choice;
while (true) {
cout << "Nhập lựa chọn của bạn (0–6): ";
cin >> choice;
if (cin.fail()) {
cin.clear(); // xóa cờ lỗi
cin.ignore(1000, '\n'); // bỏ qua ký tự sai
cout << "Vui lòng nhập một số nguyên!\n";
}
else if (choice < 0 || choice > 6) {
cout << "Không hợp lệ, vui lòng nhập lại.\n";
}
else {
return choice;
}
}
}