Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- void AdmOrCl(int i,char *answerPtr);
- void adminLogin();
- void funcNotif(char x[],char *appPtr);
- void funcRegi(char y[],int i);
- void AdminHomeS(int i,char *accessPtr);
- void ClientLogScr(char *clientlogPtr);
- void funcLog(int i);
- void UserToPass(char *Ptr);
- void funcClScreen(char *clAccessPtr);
- void funcInfo();
- char ClientArray[12][50];
- int main() {
- char ansApp[5],access[20],answer[8],clientLogin[10],ClAccess[13];
- //**************HOME SCREEN *********************
- AdmOrCl(0,answer);
- while (1) {
- if (strcmp(ClAccess,"Exit")==0) {
- AdmOrCl(0,answer);
- }
- if (strcmp(answer,"Admin")==0) {
- do {
- if ((strcmp(access,"Notifications")==0)||(strcmp(access,"View")==0)||(strcmp(access,"Search")==0)) {
- exit(EXIT_SUCCESS);
- }
- if (strcmp(access,"Exit")==0) {
- AdmOrCl(0,answer);
- if (strcmp(answer,"Client")==0) {
- strcpy(ClAccess," ");
- break;
- }
- }
- adminLogin();
- AdminHomeS(0,access); //ADMIN SCREEN
- }
- while ((strcmp(access,"Exit")==0));
- }
- else {
- ClientLogScr(clientLogin);
- if (strcmp(clientLogin,"Register")==0) {
- funcRegi(ClientArray[0],0);
- AdmOrCl(-1,answer);
- adminLogin();
- AdminHomeS(1,access);
- funcNotif(ClientArray[0],ansApp);
- if (strcmp(ansApp,"Yes")==0) {
- AdmOrCl(1,answer);
- funcLog(1);
- }
- else {
- do {
- AdmOrCl(1,answer);
- funcRegi(ClientArray[0],1);
- AdmOrCl(-1,answer);
- adminLogin();
- AdminHomeS(1,access);
- funcNotif(ClientArray[0],ansApp);
- }
- while (strcmp(ansApp,"Yes")!=0);
- AdmOrCl(1,answer);
- funcLog(1);
- }
- }
- else {
- funcLog(2);
- }
- funcClScreen(ClAccess);
- if (strcmp(ClAccess,"Information")==0) {
- funcInfo();
- int i=0;
- system("pause");
- for (i=0;i<6;i++) {
- printf ("\n\n %s\n",&ClientArray[i]);
- }
- system("pause");
- }
- else {
- printf("\n\n\n\t\t Thank you for choosing us !");
- printf("\n\n\t ");
- system("pause");
- strcpy(answer," ");
- }
- }
- }
- return 0;
- }
- void AdmOrCl(int i,char *answerPtr) {
- system("cls");
- printf("\n\t\t\t ~ Home Screen ~");
- do {
- printf("\n\n\n\t\tEnter as (Admin / Client): ");
- scanf("%s",answerPtr);
- }
- while (((strcmp(answerPtr,"Client")!=0)||(i!=1)) && ((strcmp(answerPtr,"Admin")!=0)||(i!=-1)) && (((strcmp(answerPtr,"Admin")!=0)&&(strcmp(answerPtr,"Client")!=0))||(i!=0)));
- system("cls");
- }
- void adminLogin() {
- char adminUser[8],adminPass[8];
- system("cls");
- printf("\n\n\t\t\t ~ Admin's login screen ~");
- do {
- printf("\n\n\n\t\t Username: ");
- scanf("%s",&adminUser);
- }
- while ((strcmp(adminUser,"admin")!=0));
- do {
- printf("\n\n\t\t Password: ");
- scanf("%s",&adminPass);
- }
- while ((strcmp(adminPass,"pizza")!=0));
- system("cls");
- }
- void AdminHomeS(int i,char *accessPtr) {
- char accessNotif[5];
- printf("\n\n\t\t\t ~~ ADMIN'S SCREEN ~~");
- if (i==1) {
- printf("\n\n\n\t 1)Notifications (1)");
- }
- else {
- printf("\n\n\n\t 1)Notifications");
- }
- printf("\n\n\t 2)View");
- printf("\n\n\t 3)Search");
- printf("\n\n\t 4)Exit");
- if (i==1) {
- do {
- printf("\n\n\n\t\t\tGet access to notifications? : ");
- scanf("%s",accessNotif);
- }
- while (strcmp(accessNotif,"Yes")!=0);
- }
- else {
- do {
- printf("\n\n\n\t\t\t\tGet access to: ");
- scanf("%s",accessPtr);
- }
- while ( (strcmp(accessPtr,"Notifications")!=0)&&
- (strcmp(accessPtr,"View")!=0)&&
- (strcmp(accessPtr,"Search")!=0)&&
- (strcmp(accessPtr,"Exit")!=0));
- }
- }
- void ClientLogScr(char *clientlogPtr) {
- system("cls");
- printf("\n\n\t\t\t ~ Client's login screen ~" "\n\n\n\t\tRegister.\t\t\tLogin." "\n\t\t(Create new account).\t\t(Already have an account).");
- do {
- printf("\n\n\n\t Select the way you want to join: ");
- scanf("%s",clientlogPtr);
- }
- while ((strcmp(clientlogPtr,"Register")!=0)&&(strcmp(clientlogPtr,"Login")!=0));
- }
- void funcLog(int i) {
- char RegUsC[10],a[10],b[10];
- system("cls");
- if (i==1) {
- printf("\n\n\t\t\t ~Login screen~");
- printf("\n\n\t\t Your username has been approved.");
- strcpy(RegUsC,ClientArray[0]);
- UserToPass(ClientArray[0]);
- printf("\n\n\t\t Your password is: %s",ClientArray[0]);
- do {
- printf("\n\n\n\n\n\t\tType your username: ");
- scanf("%s",&a);
- }
- while (strcmp(a,RegUsC)!=0);
- do {
- printf("\n\n\t\tType your password: ");
- scanf("%s",&a);
- }
- while (strcmp(a,ClientArray[0])!=0);
- strcpy(ClientArray[0],RegUsC);
- }
- else {
- printf("\n\n\t\t\t ~Login screen~");
- printf("\n\n\n\n\n\tType your username: ");
- scanf("%s",&ClientArray[0]);
- strcpy(b,ClientArray[0]);
- UserToPass(ClientArray[0]);
- do {
- printf("\n\n\tType your password: ");
- scanf("%s",&a);
- }
- while(strcmp(a,ClientArray[0])!=0);
- strcpy(ClientArray[0],b);
- }
- printf("\n\n\n\t\t\t Correct credentials!");
- printf("\n\n\t\t");
- system("pause");
- }
- void funcRegi(char y[],int i) {
- system("cls");
- if (i==1) {
- printf("\n\n\t\t\t ~Register screen~");
- printf("\n\n\t\t Your username hasn't been approved.");
- printf("\n\n\n\tType a valid username: ");
- scanf("%s",y);
- }
- else {
- printf("\n\n\t\t\t ~Register screen~");
- printf("\n\n\n\tType your username: ");
- scanf("%s",y);
- }
- }
- void funcNotif(char x[],char *appPtr) {
- system("cls");
- printf("\n\n\t\t\t ~~ ADMIN'S SCREEN ~~" "\n\n\n\t You have 1 notification." "\n\n\t\tUsername: %s",x);
- do {
- printf("\n\n\t Approve?: ");
- scanf("%s",appPtr);
- }
- while ((strcmp(appPtr,"Yes")!=0)&&(strcmp(appPtr,"No")!=0));
- }
- void UserToPass(char *Ptr) {
- while (*Ptr != '\0') {
- *Ptr = toupper( *Ptr );
- Ptr+=2;
- }
- }
- void funcClScreen(char *clAccessPtr) {
- system("cls");
- printf("\n\n\t\t Welcome to the Client's Home Page!");
- printf("\n\n\n\t 1)Information");
- printf("\n\n\n\t 2)Order");
- printf("\n\n\n\t 3)Exit");
- do {
- printf("\n\n\n\n\t\t\t Get access to: ");
- scanf("%s",clAccessPtr);
- }
- while ((strcmp(clAccessPtr,"Information")!=0)&&(strcmp(clAccessPtr,"Exit")!=0));
- }
- void funcInfo() {
- int i;
- printf("\n\n\n\t\tPlease complete your personal info: ");
- printf("\n\n\t\t Name: ");
- scanf(" %s",ClientArray[1]);
- printf("\n\t\t Surname: ");
- scanf(" %s",ClientArray[2]);
- printf("\n\t\t Street: ");
- scanf(" %s",ClientArray[3]);
- printf("\n\t\t Street number: ");
- scanf(" %s",ClientArray[4]);
- printf("\n\t\t Postal code: ");
- scanf(" %s",ClientArray[5]);
- for (i=0;i<7;i++) {
- printf("\n %s",&ClientArray[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement