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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>
using namespace std;
char menu(void);
void adminControl(void);
void userAccess(void);
void useModify(void);
void appendFile(void);
void displayFile(void);
void updatePasscode(void);
int main() //First Menu Options
{
char choice{};
choice = menu();
switch(choice)
{
case 'A':
cout << "\nCase A" << endl;
case 'U':
cout << "\nCase U" << endl;
case 'Q':
cout << "\nCase Q" << endl;
default:
break;
}
return 0;
}
char menu(void) // Select Admin or User
{
char choice = ' ';
do
{
cout << "Select Level of Authority: " << endl << endl;
cout << "(A)dmin, (U)ser" << endl;
cin >> choice;
choice = toupper(choice);
if (choice != 'A' && choice != 'U' && choice != 'Q')
cout << "\n Invalid Entry! Please Try Again!\n";
}
while (choice != 'A' && choice != 'U' && choice != 'Q');
return choice;
}
void adminControl(void) // Modify user access, Display Files, Update passcode
{
char choice = ' ';
cout << "What would you like to do?" << endl;
cout << "(M)odify User, (D)isplay Files, (U)pdate Passcode" << endl;
cin >> choice;
while (choice == 'M' || choice == 'D')
{
switch (choice)
{
case 'M':
useModify();
break;
case 'D':
displayFile();
break;
case 'U':
updatePasscode();
break;
}
}
}
void useModify(void)
{
cout << "\n In useModify Function.";
}
void displayFile(void)
{
cout << "Display File." << endl;
}
void updatePasscode(void)//Password Change Code
{
}
void userAccess(void) //Read or Append files, update own password
{
char choice = ' ';
cout << "What would you like to do?" << endl;
cout << "(A)ppend, (D)isplay Files, (U)pdate Passcode" << endl;
cin >> choice;
while (choice == 'A' || choice == 'D' || choice == 'U')
{
switch (choice)
{
case 'A':
appendFile();
break;
case 'D':
displayFile();
break;
case 'U':
updatePasscode();
break;
}
}
void appendFile(void)
{
cout << "Append File" << endl;
}
void displayFile(void)
{
cout << "Display File." << endl;
}
/*void updatePasscode(void)
{
/*int main() //Password Change Code
{
const int MAX_CHARS_PER_LINE = 1000;
string pepper;
ifstream sauce("C:/users/yournamehere/desktop/Program variable files/User Info.txt");
char charsFromFile[MAX_CHARS_PER_LINE];
sauce.getline(charsFromFile, MAX_CHARS_PER_LINE);
cout << "Enter the password: " << endl;
cin >> pepper;
if (pepper == charsFromFile)
{
//code
}
else
{
cout << "Intruder! Leave now!";
}
cin.get();
return 0;
}
}*/
}
/* int main() //this code program will be used for both Admin and Users
{
int passcode = 1234; //how would i modify this for different user passcodes, set length and limitations for length, alphanumerical inputs, and special characters?
int input;
int tries = 3;
cout << "Enter passcode";
cin >> input;
if (input == passcode) //passcode loop
cout << "Success!\n";
else if (input != passcode) //You need a condition for your else if statement
{
while (input != passcode)
{
cout << "Sorry try again, you have " << tries-- << " left.\n";
cin >> input;
if (tries == 0 && input !=passcode)
{
cout << "Sorry you have exceeded the maximum attempts\n";
return 0;
}
else if (tries == 0 && input == passcode) //ensures program recognizes correct input, program just ends if I don't add this.
{
cout << "Authorized!\n";
}
else if (input == passcode) // if I don't have this, program does not work if you input the correct passcode on any attempts other than the first one.
{
cout << "Intruder!\n";
}
}
}
return 0;
}*/
/*int main() //Password Set Code
{
string password;
cout << "Set the password" << endl;
ofstream myfile("C:/users/youtube area/desktop/Program variable files/User Info.txt");
if (myfile.is_open())
{
cin >> password;
myfile << password;
cout << "Your new password is " << password << endl;
}
return 0;
}*/
| |