2015-10-06 00:00:26 -05:00
|
|
|
//#include <iostream>
|
|
|
|
#include "User.h"
|
2015-10-01 13:38:24 -05:00
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
using namespace std;
|
|
|
|
|
2015-10-06 00:00:26 -05:00
|
|
|
vector<User> users;
|
|
|
|
|
|
|
|
// struct loginCredentials
|
|
|
|
// {
|
|
|
|
// string name;
|
|
|
|
// string password;
|
|
|
|
|
|
|
|
// loginCredentials(string n, string p)
|
|
|
|
// {
|
|
|
|
// name = n;
|
|
|
|
// password = p;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
void yourAccount()
|
|
|
|
{
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"*********************************"<<endl;
|
|
|
|
cout<<"Your Account"<<endl;
|
|
|
|
cout<<"*********************************\n"<<endl;
|
|
|
|
cout<<"\n\nname: JOHN CENA"<<endl;
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"other stuff related to this user\n\n"<<endl;
|
|
|
|
cout<<"0. Return to main menu"<<endl;
|
|
|
|
cout<<"\n\nEnter choice:";
|
2015-09-29 23:06:39 -05:00
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void goToBoard()
|
|
|
|
{
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"*********************************"<<endl;
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"Board x"<<endl;
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"*********************************\n"<<endl;
|
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"0. Return to main menu"<<endl;
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"3. back to board menu"<<endl;
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"\n\nEnter choice:";
|
2015-09-29 23:06:39 -05:00
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void boardList()
|
|
|
|
{
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"\n\nShowing all boards:"<<endl;
|
|
|
|
|
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"0. Return to main menu"<<endl;
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"3. Return to board menu"<<endl;
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"\n\nEnter choice:";
|
2015-09-29 23:06:39 -05:00
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-01 13:38:24 -05:00
|
|
|
void boardMenu()
|
2015-09-29 22:49:18 -05:00
|
|
|
{
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"*********************************"<<endl;
|
|
|
|
cout<<"Board Menu"<<endl;
|
|
|
|
cout<<"*********************************\n"<<endl;
|
|
|
|
cout<<"\n\n4. List of boards"<<endl;
|
|
|
|
cout<<"5. Go to board (enter shortcut[first few characters])"<<endl;
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"0. Return to main menu"<<endl;
|
|
|
|
cout<<"\n\nEnter choice:";
|
2015-10-01 13:38:24 -05:00
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void showMessages()
|
|
|
|
{
|
|
|
|
cout<<"Messages will be displayed soon"<<endl;
|
|
|
|
//do some stuff to display messages
|
2015-10-01 13:38:24 -05:00
|
|
|
|
|
|
|
cout<<"\n0. Return to main menu"<<endl;
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"\n\nEnter choice:";
|
2015-09-29 23:06:39 -05:00
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void showGroups()
|
|
|
|
{
|
|
|
|
cout<<"Groups will be displayed soon"<<endl;
|
2015-10-01 13:38:24 -05:00
|
|
|
|
|
|
|
cout<<"\n0. Return to main menu"<<endl;
|
|
|
|
cout<<"\n\nEnter choice:";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-10-06 00:00:26 -05:00
|
|
|
void createNewAccount(string n, string pass, string phone, string fax, string postal, bool admin)
|
|
|
|
{
|
|
|
|
User newUser(n,pass,phone,fax,postal,admin);
|
|
|
|
users.push_back(newUser);
|
|
|
|
|
|
|
|
cout<<"current users:"<<endl;
|
|
|
|
|
|
|
|
for(int i = 0; i < users.size(); ++i)
|
|
|
|
{
|
|
|
|
cout<<users[i].getName()<<endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-01 13:38:24 -05:00
|
|
|
void newAccount()
|
|
|
|
{
|
|
|
|
cout<<"*********************************"<<endl;
|
|
|
|
cout<<"Request new account"<<endl;
|
|
|
|
cout<<"*********************************\n"<<endl;
|
2015-10-06 00:00:26 -05:00
|
|
|
|
|
|
|
string n, pass, phone, fax, postal;
|
|
|
|
|
|
|
|
cout<<"Name: "<<endl;
|
|
|
|
cin>>n;
|
|
|
|
|
|
|
|
cout<<"\nPassword: "<<endl;
|
|
|
|
cin>>pass;
|
|
|
|
|
|
|
|
cout<<"\nPhone: "<<endl;
|
|
|
|
cin>>phone;
|
|
|
|
|
|
|
|
cout<<"\nFax: "<<endl;
|
|
|
|
cin>>fax;
|
|
|
|
|
|
|
|
cout<<"Postal code: "<<endl;
|
|
|
|
cin>>postal;
|
|
|
|
|
|
|
|
createNewAccount(n,pass,phone,fax,postal,false);
|
|
|
|
|
|
|
|
cout<<"account successfully created!"<<endl;
|
|
|
|
|
2015-10-01 13:38:24 -05:00
|
|
|
cout<<"\n8. Return to login menu"<<endl;
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"\n\nEnter choice:";
|
2015-09-29 23:06:39 -05:00
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void mainMenu()
|
|
|
|
{
|
2015-10-01 13:38:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
cout<<"\n\n***************"<<endl;
|
|
|
|
cout<<"** Main Menu **"<<endl;
|
|
|
|
cout<<"***************\n"<<endl;
|
|
|
|
cout<<"\n6. Your account"<<endl;
|
|
|
|
cout<<"3. Boards"<<endl;
|
|
|
|
cout<<"2. Messages"<<endl;
|
|
|
|
cout<<"1. Groups\n"<<endl;
|
|
|
|
cout<<"8. Logout\n"<<endl;
|
|
|
|
cout<<"Enter choice: ";
|
|
|
|
}
|
|
|
|
|
2015-10-06 00:00:26 -05:00
|
|
|
bool verifyCredentials(string n, string p)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < users.size(); ++i)
|
|
|
|
{
|
|
|
|
if (users[i].getName() == n && users[i].getPassword() == p)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-10-01 13:38:24 -05:00
|
|
|
void loginMenu()
|
2015-10-06 00:00:26 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
string name;
|
|
|
|
string password;
|
|
|
|
|
|
|
|
//loginCredentials c(name,password);
|
|
|
|
|
|
|
|
cout<<"\n\n****************"<<endl;
|
|
|
|
cout<<"****** Login Menu **"<<endl;
|
|
|
|
cout<<"****************\n\n"<<endl;
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
|
|
|
|
cout<<"\nUsername: "<<endl;
|
|
|
|
cin>>name;
|
|
|
|
cin.clear();
|
|
|
|
cin.ignore();
|
|
|
|
|
|
|
|
cout<<"\nPassword: "<<endl;
|
|
|
|
cin>>password;
|
|
|
|
cin.clear();
|
|
|
|
cin.ignore();
|
|
|
|
|
|
|
|
if (verifyCredentials(name,password))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cout<<"Invalid credentials!"<<endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mainMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void startMenu()
|
2015-10-01 13:38:24 -05:00
|
|
|
{
|
|
|
|
cout<<"\n\n** Enter BBS **"<<endl;
|
|
|
|
cout<<"0. Login"<<endl;
|
|
|
|
cout<<"7. Request new account\n\n";
|
|
|
|
cout<<"-1. Exit\n\n"<<endl;
|
|
|
|
cout<<"Enter choice: ";
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-01 13:38:24 -05:00
|
|
|
void eventHandler(int choice)
|
|
|
|
{
|
|
|
|
switch(choice)
|
|
|
|
{
|
2015-10-06 00:00:26 -05:00
|
|
|
case 0: loginMenu(); break;
|
2015-10-01 13:38:24 -05:00
|
|
|
case 1: showGroups(); break;
|
|
|
|
case 2: showMessages(); break;
|
|
|
|
case 3: boardMenu(); break;
|
|
|
|
case 4: boardList(); break;
|
|
|
|
case 5: goToBoard(); break;
|
|
|
|
case 6: yourAccount(); break;
|
|
|
|
case 7: newAccount(); break;
|
2015-10-06 00:00:26 -05:00
|
|
|
case 8: startMenu(); break;
|
2015-10-01 13:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
int main()
|
|
|
|
{
|
2015-10-06 00:00:26 -05:00
|
|
|
//needs to load all the relations - at least the user relation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User u0("JOHN_CENA", "UberWrestling", "111-222-3333", "444-555-6666", "77432", true);
|
|
|
|
User u1("user1", "gig'em!", "111-222-3333", "444-555-6666", "77432", false);
|
|
|
|
|
|
|
|
User u2("user1", "gig'em!", "111-222-3333", "444-555-6666", "77432", false);
|
|
|
|
User u3("user2", "gig'em!", "111-222-3333", "444-555-6666", "77432", false);
|
|
|
|
User u4("user3", "gig'em!", "111-222-3333", "444-555-6666", "77432", false);
|
|
|
|
|
|
|
|
users.push_back(u0);
|
|
|
|
users.push_back(u1);
|
|
|
|
users.push_back(u2);
|
|
|
|
users.push_back(u3);
|
|
|
|
users.push_back(u4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DBEngine v8;
|
|
|
|
|
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
cout<<"***************************************"<<endl;
|
|
|
|
cout<<"Welcome to our BBS "<<endl;
|
|
|
|
cout<<"***************************************"<<endl;
|
|
|
|
|
2015-10-01 13:38:24 -05:00
|
|
|
eventHandler(8);
|
|
|
|
|
2015-09-29 22:49:18 -05:00
|
|
|
int choice;
|
|
|
|
|
|
|
|
|
2015-10-01 13:38:24 -05:00
|
|
|
while (choice != -1)
|
|
|
|
{
|
|
|
|
cin>>choice;
|
|
|
|
eventHandler(choice);
|
|
|
|
}
|
2015-09-29 22:49:18 -05:00
|
|
|
}
|
2015-10-06 00:00:26 -05:00
|
|
|
|