-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.cpp
87 lines (77 loc) · 1.43 KB
/
Menu.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "Menu.h"
#include <iostream>
#include "Chess.h"
#include"Accounts.h"
#pragma once
using namespace std;
Menu::Menu()
{
}
void Menu::AddAcount()
{
string mail, password;
cout << "\nPlease enter email: ";
getline(cin, mail);
cout << "\nPlease enter password: ";
getline(cin, password);
data.new_account(mail, password);
}
int Menu::Login()
{
string mail, password;
int indexOfMail;
bool login=false;
do {
cout << "\nPlease enter email: ";
getline(cin, mail);
indexOfMail = data.email_search(mail);// For storing the index of email
if (indexOfMail == -1)
{
cout << "\nEmail Not found!!";
}
else
{
cout << "\nPlease enter Password: ";
getline(cin, password);
if (data.password_check(indexOfMail, password))
{
login = true;
cout << "\nLogin Sucessful!";
}
else
{
cout << "\nWrong Password;";
}
}
} while (login);
return indexOfMail;
}
void Menu::ShowMenu()
{
// Please add appropriate menu
int choice;
cin >> choice;
switch (choice)
{
//For login
case 1:
cout << "\nPlease enter account information for White:" << endl;
White = Login();
cout << "\nPlease enter account information for Black:" << endl;
Black = Login();
break;
//New Account
case 2:
AddAcount();
break;
// For exiting the program
case 3:
exit(1);
break;
default:
break;
}
}
Menu::~Menu()
{
}