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
|
void login(){
create c;
char usernameConfig[15];
char passwordConfig[15];
char username[15];
char password[15];
char sub[15], concat[15];
int time;
int load=0.00;
int ctr;
int timeConfig;
int loadConfig=0.00;
int newTime;
int newLoad=0.00;
bool repeat = true;
char choicee;
cout<<"\n\n\t\tEnter username: ";
cin.getline(username,15);
cout<<"\n\n\t\tEnter password:";
cin.getline(password,15);
ifstream newfile;
ifstream myfile;
ifstream myfile1;
ofstream myfile2;
newfile.open("counter.txt");
if(newfile.is_open()){
newfile >> ctr;
newfile.close();
}
for(int x=1; x<ctr+1; x++){
strcpy(concat,"account");
strcat(concat,"[");
itoa (x,sub,10);
strcat(concat,sub);
strcat(concat,"].txt");
myfile.open(concat);
if(myfile.is_open()){
myfile >> usernameConfig;
myfile >> passwordConfig;
myfile.close();
}
if(strcmp(username,usernameConfig)==0 && strcmp(password, passwordConfig)==0){
strcpy(concat,"bcount");
strcat(concat,"[");
itoa (x,sub,10);
strcat(concat,sub);
strcat(concat,"].txt");
myfile1.open(concat);
if(myfile1.is_open()){
myfile1 >> time;
myfile1 >> load;
myfile1.close();
}
cout<<"\n\n\t\tWelcome, "<<username;
cout<<"\n\t\tTotal time: ";
cout<<time<<"hrs";
cout<<"\n\t\tTotal mount payed: ";
cout<<"P "<<load<<".00";
cout<<"\n\n\t\t[A] Start session";
choicee = getch();
switch(choicee){
case 'a':
int sec;
sec = 60;
int min;
min=59;
int hour;
hour = time-1;
while(true){
Sleep(1000);
sec = sec-1;
if(sec==0){
min=min-1;
sec=60;
}
if(min==0){
hour = hour-1;
min = 59;
}
system("cls");
cout<<"\n\n\t\tTime: "<<
cout<<"\n\t\t"<<hour<<" hrs "<<min<<" mins "<<sec<<" sec"<<endl;
myfile2.open("pc1.txt");
myfile2 << "off";
myfile2 <<hour;
myfile2 <<min;
myfile2 <<sec;
myfile2.close();
Sleep(1000);
}
getch();
}
| |