Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip> //setw
- #include <cmath> // math
- #include <fstream>
- #include <cstring>
- #include <string>
- #include <map>
- #include <algorithm>
- using namespace std;
- // Big Daddy Menu ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- // hey future coder, when menu is written it needs parameters
- // username,
- void menu(string username, string password) {
- cout << "Hi";
- }
- // USERS ********************************************************
- void addNewMembers(string name, string encrypt) { // parameters are put to figure use variables in other functions of code
- string save;
- ofstream Users; // file stream
- Users.open("txt/Users.txt", ios::app);
- if(Users.is_open()) {
- Users << name << ':' << encrypt << '\n'; // appends to file called Users
- } else {
- cout << "Error with file opening";
- }
- Users.close();
- save = name + "." + encrypt;
- menu(name, save);
- }
- void algorithmNewUser(string ps, string name_of_user) {
- string hashnsalt; // acts sorta like a transitional function
- reverse(ps.begin(),ps.end());
- hashnsalt = ps + "6" ;
- reverse(hashnsalt.begin(),hashnsalt.end());
- hashnsalt += "8";
- reverse(hashnsalt.begin(),hashnsalt.end());
- // cout << hashnsalt << "\n"; #++++++++++++++++++ FLAG ALERT
- addNewMembers(name_of_user, hashnsalt);
- }
- void newUser() {
- string username, password;
- cout << "Input a new username: ";
- cin >> username;
- while((4) != password.length()) { // if length != 4 then keep running
- cout << "Input a 4 number pin as a password: ";
- cin >> password;
- }
- algorithmNewUser(password, username);
- }
- //////////////////////////////////////// THE GREAT WALL OF USERS
- void welcomingReturningMember(string ps, string userName) { // welcomes returning user and also checks for username via password
- string username, key, line, save;
- int elseChoice;
- int j = 1; // it's the runner again
- fstream Users;
- key = userName + ":" + ps;
- Users.open("txt/Users.txt");
- if(Users.is_open()) {
- while (!Users.eof() && (j == 1)) {
- getline(Users,line);
- if(key == line) {
- cout << "Welcome back, " << userName << "!";
- break;
- }
- else {
- cout << "User not found\n";
- cout << "New Account?\n[Enter integer]\n1.Yes\n2.No\n>";
- cin >> elseChoice;
- switch(elseChoice) {
- case 1:
- j -= 1;
- newUser();
- break;
- case 2:
- j -= 1;
- cout << "Too bad, you are becoming a New Member\n\n";
- newUser();
- break;
- default:
- cout << "Okay well, that's not a choice";
- }
- }
- }
- } else {
- cout << "File not working";
- }
- save = userName + "." + ps;
- menu(userName, save);
- }
- void returningUserAlgorithm(string pswd, string user) {
- string saltyhash; // just a standard decaration fam
- reverse(pswd.begin(),pswd.end()); // reverses the order
- saltyhash = pswd + "6";
- reverse(saltyhash.begin(),saltyhash.end());
- saltyhash += "8";
- reverse(saltyhash.begin(),saltyhash.end());// finishes the 6br8-Algoritm
- welcomingReturningMember(saltyhash, user);
- }
- void returningUser() {
- string username, password;
- cout << "Enter username: ";
- cin >> username;
- while((4) != password.length()) {
- cout << "Enter password: ";
- cin >> password;
- }
- returningUserAlgorithm(password, username);
- }
- void user() {
- int user_choice, runner = 1;
- string user_prompt;
- while(runner == 1) {
- user_prompt = "[Enter digit]\n1.New User\n2.Returning User\n>";
- cout << user_prompt;
- cin >> user_choice;
- switch(user_choice) {
- case 1:
- runner -= 1;
- newUser();
- break;
- case 2:
- runner -= 1;
- returningUser();
- break;
- default:
- cout << "Not a valid choice";
- break;
- }
- }
- }
- //
- void buyingMenu() {
- int runner = 1;
- char userChoice;
- while (runner == 1) {
- cout << "Inventory: ";
- cout << "1: Father Azzarto Bobblehead: 25 Tokens.\n";
- cout << "2: Gloves: 7 Tokens.\n";
- cout << "3: Large Duffle Bag: 30 Tokens.\n";
- cout << "4: Winter Had: 20 Tokens.\n";
- cout << "5: Black Quilted Jacket: 45 Tokens.\n";
- cout << "6: Varsity Sweater: 50 Tokens.\n";
- cout << "7: Prep Socks: 15 Tokens.\n";
- cout << "8: Tie Bar: 10 Tokens.\n";
- cout << "9: Blue Prep Tie: 30 Tokens.\n";
- cout << "10: SPP Belt: 25 Tokens.\n";
- cout << "\nSelect what item you want to buy [1-10]: \n";
- cin >> userChoice;
- switch(userChoice) {
- case 1:
- break;
- } // switch statement
- } // while loop
- }
- // Lil God ########################################################
- int main() {
- cout << "Prep Campus Shop_V2" << "\n==========================\n";
- user();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement