diff --git a/ERD_Project.html b/ERD_Project.html new file mode 100644 index 0000000..1ceb9f8 --- /dev/null +++ b/ERD_Project.html @@ -0,0 +1,12 @@ + + + + +ERD_Project.html + + + +
+ + + diff --git a/ERD_Project.png b/ERD_Project.png new file mode 100644 index 0000000..1de5e58 Binary files /dev/null and b/ERD_Project.png differ diff --git a/InGameMenu.cpp b/InGameMenu.cpp index b3718ef..dda5303 100644 --- a/InGameMenu.cpp +++ b/InGameMenu.cpp @@ -1,254 +1,258 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; -#include "libsqlite.hpp" -#include "md5.h" -#include - -// fazer setting, mudar pass, ver os dados tipo nacionalidade, idade, caracteristicas (mentalidade, ) , - -class PlayerInfo { - - - public: - - - - void changePassword(int Player_ID) - { - newpass: - string password, veriyPassword; - cout<<"Insert the new Password"<> password ; - cout << "Insert tha same password" << endl ; - cout << "Repeat Password: "; - cin >> veriyPassword ; - } - while(password != veriyPassword); - string ecryptedPassword = md5(password); // this is the funcition to encrypt the password, tha that i did some research about it ITS NOT MINE - - // updting the password - sqlite::sqlite db( "ball.sqlite" ); - auto cur = db.get_statement(); - cur->set_sql( " UPDATE Player SET Password = ? WHERE Player_ID = ? ; " ); - cur->prepare(); - cur->bind( 1, ecryptedPassword ); - cur->bind( 2, Player_ID ); - int result= cur->step(); - if (result == true) - { - cout<<"Password Updated Sucessful"<> age; - cout << "Input your email"<< endl; - cin>> email; - cout << "Input your mentality"<< endl; - cin>> mentality; - cout << "Input your nationality"<< endl; - cin>> nationality; - cout << "Input your favourite club"<< endl; - cin>> favourite_club; - - // updting edtails on BD - sqlite::sqlite db( "ball.sqlite" ); - auto cur = db.get_statement(); - cur->set_sql( " UPDATE Player SET Email = ? , Mentality = ? , Age = ? , Nationality = ? , Club = ? WHERE Player_ID = ? ; " ); - cur->prepare(); - cur->bind( 1, email ); - cur->bind( 2, mentality ); - cur->bind( 3, age ); - cur->bind( 4, nationality ); - cur->bind( 5, favourite_club ); - cur->bind( 6, Player_ID ); - int result= cur->step(); - if (result == true) - { - cout<<"Details Updated Sucessful"<set_sql( " SELECT * FROM Player WHERE Player_ID = ? ; " ); - cur->prepare(); - cur->bind( 1, Player_ID ); - - while( cur->step() ) - { // loop over results# - cout << "*******************************\n"; - cout << "Here are you actual details"<< endl; - cout << "UserName:" << cur->get_text(1) << endl; - cout << "Email:" << cur->get_text(2) << endl; - cout << "Mentality:" << cur->get_text(4) << endl; - cout << "Age:" << cur->get_int(5) << endl; - cout << "Nationality:" << cur->get_text(6) << endl; - cout << "Favorite Club:" << cur->get_text(7) << endl; - cout << "*******************************\n"; - - } - - - } - -};// end clas PlayerInfo - -// // function to display the Menu after you logged in -int MenuGame(int Player_ID){ - char choice; - - MenuInGame: - do + #include + #include + #include + #include + #include + #include + #include + #include + #include + using namespace std; + #include "libsqlite.hpp" + #include "md5.h" + #include + + + + class PlayerInfo { + + + public: + + + + void changePassword(int Player_ID, sqlite::sqlite &db ) { + newpass: + string password, veriyPassword; + cout<<"Insert the new Password"<> password ; + cout << "Insert tha same password" << endl ; + cout << "Repeat Password: "; + cin >> veriyPassword ; + } + while(password != veriyPassword); + cout<< "encorou "<< password<set_sql( " UPDATE Player SET Password = ? WHERE Player_ID = ? ; " ); + cur->prepare(); + cur->bind( 1, ecryptedPassword ); + cur->bind( 2, Player_ID ); + cur->step(); + int result= cur->step(); + if (result == 0) + { + cout<<"Password Updated Sucessful"<> choice; - - } // end of do while - while (choice >'5' || choice<'0' ); - - switch (choice) - { - case '1': - { - - - - break; - } // end case 1 play game - case '2': - { - - - break; - }//end case 2 my team - - case '3':{ - cout << "Market BallManager"<< endl; - break; - - }// end case 3 market - - case '4':{ - MenuSettings: - do - { + }//end changePassword + + void updateDetails(int Player_ID, sqlite::sqlite &db) // function that alows the user to updtade his details like mail, mentality, age, favourite club. + { + update: + string email, mentality, nationality, favourite_club; + int age; + cout << "Input your age"<< endl; + cin>> age; + cout << "Input your email"<< endl; + cin>> email; + cout << "Input your mentality"<< endl; + cin>> mentality; + cout << "Input your nationality"<< endl; + cin>> nationality; + cout << "Input your favourite club"<< endl; + cin>> favourite_club; + + // updting edtails on BD + //sqlite::sqlite db( "ball.sqlite" ); + auto cur = db.get_statement(); + cur->set_sql( " UPDATE Player SET Email = ? , Mentality = ? , Age = ? , Nationality = ? , Club = ? WHERE Player_ID = ? ; " ); + cur->prepare(); + cur->bind( 1, email ); + cur->bind( 2, mentality ); + cur->bind( 3, age ); + cur->bind( 4, nationality ); + cur->bind( 5, favourite_club ); + cur->bind( 6, Player_ID ); + int result= cur->step(); + if (result == 0) + { + cout<<"Details Updated Sucessful"<set_sql( " SELECT * FROM Player WHERE Player_ID = ? ; " ); + cur->prepare(); + cur->bind( 1, Player_ID ); + + while( cur->step() ) + { // loop over results# + cout << "*******************************\n"; + cout << "Here are you actual details"<< endl; + cout << "UserName:" << cur->get_text(1) << endl; + cout << "Email:" << cur->get_text(2) << endl; + cout << "Mentality:" << cur->get_text(4) << endl; + cout << "Age:" << cur->get_int(5) << endl; + cout << "Nationality:" << cur->get_text(6) << endl; + cout << "Favorite Club:" << cur->get_text(7) << endl; + cout << "*******************************\n"; - cin >> choice; + } - } // end of do while - while (choice >'5' || choice<'0' ); - switch (choice) + } + + };// end clas PlayerInfo + + // // function to display the Menu after you logged in + int MenuGame(int Player_ID, sqlite::sqlite &db){ + char choice; + + //sqlite::sqlite db( "ball.sqlite" ); + + MenuInGame: + do + { + + cout << "*******************************\n"; + cout << " 1 - Play Game."<< endl; + cout << " 2 - Manage My Team "<< endl; + cout << " 3 - Market"<< endl; + cout << " 4 - Setings "<< endl; + cout << " 5 - Exit."<< endl; + cout << " Enter your choice and press return: "; + + + cin >> choice; + + } // end of do while + while (choice >'5' || choice<'0' ); + + switch (choice) + { + case '1': { - case '1': - { - - PlayerInfo obj1; - obj1.printDetails(Player_ID); - obj1.updateDetails(Player_ID); - - goto MenuSettings; - break; - } // end case 1 personalize yourself - case '2': - { - PlayerInfo obj1; - obj1.changePassword(Player_ID); - goto MenuSettings; - break; - }//end case 2 change password - case '3':{ - - cout << " Choice 3 "; - goto MenuInGame; - break; - }// end case 3 Go Back + break; + } // end case 1 play game + case '2': + { + + + break; + }//end case 2 my team + + case '3':{ + cout << "Market BallManager"<< endl; + break; + + }// end case 3 market - default: + case '4':{ + MenuSettings: + do { - cout << "Not a Valid Choice."<< endl; - cout << "Choose again."<< endl; - goto MenuSettings; - - break; - }// end default case MenuSettings - - - return 0; - }// end of menu - - break; - } // end Menu Setings - - case '5':{ - - cout << "End of Program."<< endl; - break; - } - - default: - { - cout << "Not a Valid Choice."<< endl; - cout << "Choose again."<< endl; - goto MenuInGame; - - break; - }// end default case - - - return 0; - }// end of menu - -}// end of MenuGame function \ No newline at end of file + + cout << "*******************************\n"; + cout << " 1 - Personalize yourself"<< endl; + cout << " 2 - Change Password "<< endl; + cout << " 3 - Go Back"<< endl; + + cout << " Enter your choice and press return: "; + + + cin >> choice; + + } // end of do while + while (choice >'5' || choice<'0' ); + + switch (choice) + { + case '1': + { + + PlayerInfo obj1; + obj1.printDetails(Player_ID, db); + obj1.updateDetails(Player_ID, db); + + goto MenuSettings; + break; + } // end case 1 personalize yourself + case '2': + { + PlayerInfo obj1; + obj1.changePassword(Player_ID, db); + goto MenuSettings; + break; + }//end case 2 change password + + case '3':{ + + cout << " Choice 3 "; + goto MenuInGame; + break; + + }// end case 3 Go Back + + + default: + { + cout << "Not a Valid Choice."<< endl; + cout << "Choose again."<< endl; + goto MenuSettings; + + break; + }// end default case MenuSettings + + + return 0; + }// end of menu + + break; + } // end Menu Setings + + case '5':{ + + cout << "End of Program."<< endl; + break; + } + + default: + { + cout << "Not a Valid Choice."<< endl; + cout << "Choose again."<< endl; + goto MenuInGame; + + break; + }// end default case + + + return 0; + }// end of menu + + }// end of MenuGame function \ No newline at end of file diff --git a/Main.cpp b/Main.cpp index 2317bb6..f92d3d1 100644 --- a/Main.cpp +++ b/Main.cpp @@ -12,6 +12,12 @@ using namespace std; int main() { + + //sqlite::sqlite db( "ball.sqlite" ); + + //PlayerInfo pi; + //pi.changePassword(7, db ); + //return 0; int Player_ID = menuu(); diff --git a/Menu.cpp b/Menu.cpp index 4e4c305..e0ddf91 100644 --- a/Menu.cpp +++ b/Menu.cpp @@ -21,7 +21,7 @@ string hashPassword(string password) return ecryptedPassword; } -int createTeam(int Player_ID, string teamName) +int createTeam(int Player_ID, string teamName ) { @@ -93,7 +93,7 @@ char menuu() if (result == true){ cout<<"login Sucessful"<