Advertisement
Guest User

aris

a guest
Jan 7th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6.  
  7.  
  8. void AdmOrCl(int i,char *answerPtr);
  9. void adminLogin();
  10. void funcNotif(char x[],char *appPtr);
  11. void funcRegi(char y[],int i);
  12. void AdminHomeS(int i,char *accessPtr);
  13. void ClientLogScr(char *clientlogPtr);
  14. void funcLog(int i);
  15. void UserToPass(char *Ptr);
  16. void funcClScreen(char *clAccessPtr);
  17. void funcInfo();
  18. char ClientArray[12][50];
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. int main() {
  28.     char ansApp[5],access[20],answer[8],clientLogin[10],ClAccess[13];
  29.    
  30.         //**************HOME SCREEN *********************
  31.     AdmOrCl(0,answer);
  32. while (1) {
  33.         if (strcmp(ClAccess,"Exit")==0) {
  34.             AdmOrCl(0,answer);
  35.         }
  36.             if (strcmp(answer,"Admin")==0) {
  37.                     do {
  38.                         if ((strcmp(access,"Notifications")==0)||(strcmp(access,"View")==0)||(strcmp(access,"Search")==0)) {
  39.                             exit(EXIT_SUCCESS);
  40.                         }
  41.                         if (strcmp(access,"Exit")==0) {
  42.                             AdmOrCl(0,answer);
  43.                             if (strcmp(answer,"Client")==0) {
  44.                                 strcpy(ClAccess," ");
  45.                                 break;
  46.                             }
  47.                         }
  48.                                 adminLogin();
  49.                                 AdminHomeS(0,access);       //ADMIN SCREEN
  50.                                                                        
  51.                     }
  52.                     while ((strcmp(access,"Exit")==0));
  53.             }
  54.             else {
  55.                 ClientLogScr(clientLogin);
  56.                     if (strcmp(clientLogin,"Register")==0) {
  57.                             funcRegi(ClientArray[0],0);
  58.                             AdmOrCl(-1,answer);
  59.                             adminLogin();
  60.                             AdminHomeS(1,access);
  61.                             funcNotif(ClientArray[0],ansApp);
  62.                                 if (strcmp(ansApp,"Yes")==0) {
  63.                                     AdmOrCl(1,answer);
  64.                                     funcLog(1);
  65.                                 }
  66.                                 else {
  67.                                     do {
  68.                                         AdmOrCl(1,answer);
  69.                                         funcRegi(ClientArray[0],1);
  70.                                         AdmOrCl(-1,answer);
  71.                                         adminLogin();
  72.                                         AdminHomeS(1,access);
  73.                                         funcNotif(ClientArray[0],ansApp);
  74.                                     }
  75.                                     while (strcmp(ansApp,"Yes")!=0);
  76.                                     AdmOrCl(1,answer);
  77.                                     funcLog(1);
  78.                                 }  
  79.                     }
  80.                     else {
  81.                             funcLog(2);
  82.                     }
  83.                     funcClScreen(ClAccess);
  84.                     if (strcmp(ClAccess,"Information")==0) {
  85.  
  86.                         funcInfo();
  87.                         int i=0;
  88.                         system("pause");
  89.                         for (i=0;i<6;i++) {
  90.                             printf ("\n\n  %s\n",&ClientArray[i]);
  91.                         }
  92.                         system("pause");
  93.                        
  94.                        
  95.                     }
  96.                     else {
  97.                         printf("\n\n\n\t\t       Thank you for choosing us !");
  98.                         printf("\n\n\t            ");
  99.                         system("pause");
  100.                         strcpy(answer," ");
  101.                     }            
  102.             }
  103. }
  104.     return 0;
  105. }
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. void AdmOrCl(int i,char *answerPtr) {
  115.         system("cls");
  116.         printf("\n\t\t\t      ~ Home Screen ~");
  117.             do {
  118.                 printf("\n\n\n\t\tEnter as (Admin / Client): ");
  119.                 scanf("%s",answerPtr);
  120.             }
  121.             while (((strcmp(answerPtr,"Client")!=0)||(i!=1)) && ((strcmp(answerPtr,"Admin")!=0)||(i!=-1)) && (((strcmp(answerPtr,"Admin")!=0)&&(strcmp(answerPtr,"Client")!=0))||(i!=0)));         
  122.         system("cls");
  123. }
  124.  
  125.  
  126.  
  127. void adminLogin() {
  128.     char adminUser[8],adminPass[8];
  129.  
  130.         system("cls");
  131.         printf("\n\n\t\t\t ~ Admin's login screen ~");
  132.         do {
  133.             printf("\n\n\n\t\t Username: ");
  134.             scanf("%s",&adminUser);
  135.         }
  136.         while ((strcmp(adminUser,"admin")!=0));
  137.         do {
  138.             printf("\n\n\t\t Password: ");
  139.             scanf("%s",&adminPass);
  140.         }
  141.         while ((strcmp(adminPass,"pizza")!=0));
  142.         system("cls");
  143. }
  144.  
  145.  
  146.  
  147. void AdminHomeS(int i,char *accessPtr) {
  148.     char accessNotif[5];
  149.    
  150.     printf("\n\n\t\t\t ~~ ADMIN'S SCREEN ~~");
  151.     if (i==1) {
  152.         printf("\n\n\n\t 1)Notifications (1)");
  153.     }
  154.     else {
  155.         printf("\n\n\n\t 1)Notifications");
  156.     }
  157.     printf("\n\n\t 2)View");
  158.     printf("\n\n\t 3)Search");
  159.     printf("\n\n\t 4)Exit");
  160.     if (i==1) {
  161.         do {
  162.             printf("\n\n\n\t\t\tGet access to notifications? : ");
  163.             scanf("%s",accessNotif);
  164.         }
  165.         while (strcmp(accessNotif,"Yes")!=0);
  166.     }
  167.     else {
  168.         do {
  169.             printf("\n\n\n\t\t\t\tGet access to: ");
  170.             scanf("%s",accessPtr);
  171.         }
  172.         while (    (strcmp(accessPtr,"Notifications")!=0)&&
  173.                (strcmp(accessPtr,"View")!=0)&&
  174.                (strcmp(accessPtr,"Search")!=0)&&
  175.                (strcmp(accessPtr,"Exit")!=0));
  176.     }  
  177. }
  178.  
  179.  
  180.  
  181. void ClientLogScr(char *clientlogPtr) {
  182.     system("cls");
  183.     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).");
  184.     do {
  185.         printf("\n\n\n\t Select the way you want to join: ");
  186.         scanf("%s",clientlogPtr);
  187.     }
  188.     while ((strcmp(clientlogPtr,"Register")!=0)&&(strcmp(clientlogPtr,"Login")!=0));
  189. }
  190.  
  191.  
  192.  
  193. void funcLog(int i) {
  194.     char RegUsC[10],a[10],b[10];
  195.     system("cls");
  196.     if (i==1) {
  197.         printf("\n\n\t\t\t ~Login screen~");
  198.         printf("\n\n\t\t Your username has been approved.");
  199.         strcpy(RegUsC,ClientArray[0]);
  200.         UserToPass(ClientArray[0]);
  201.         printf("\n\n\t\t Your password is: %s",ClientArray[0]);
  202.        
  203.         do {
  204.             printf("\n\n\n\n\n\t\tType your username: ");
  205.             scanf("%s",&a);
  206.         }
  207.         while (strcmp(a,RegUsC)!=0);
  208.        
  209.         do {
  210.             printf("\n\n\t\tType your password: ");
  211.             scanf("%s",&a);
  212.         }
  213.         while (strcmp(a,ClientArray[0])!=0);
  214.     strcpy(ClientArray[0],RegUsC);
  215.     }
  216.     else {
  217.         printf("\n\n\t\t\t ~Login screen~");
  218.             printf("\n\n\n\n\n\tType your username: ");
  219.             scanf("%s",&ClientArray[0]);
  220.                 strcpy(b,ClientArray[0]);
  221.             UserToPass(ClientArray[0]);
  222.             do {
  223.                 printf("\n\n\tType your password: ");
  224.                 scanf("%s",&a);
  225.             }
  226.             while(strcmp(a,ClientArray[0])!=0);
  227.     strcpy(ClientArray[0],b);
  228.     }
  229.     printf("\n\n\n\t\t\t Correct credentials!");
  230.     printf("\n\n\t\t");
  231.     system("pause");
  232. }
  233.  
  234.  
  235.  
  236. void funcRegi(char y[],int i) {
  237.     system("cls");
  238.     if (i==1) {
  239.         printf("\n\n\t\t\t ~Register screen~");
  240.         printf("\n\n\t\t Your username hasn't been approved.");
  241.         printf("\n\n\n\tType a valid username: ");
  242.         scanf("%s",y);
  243.     }
  244.     else {
  245.         printf("\n\n\t\t\t ~Register screen~");
  246.         printf("\n\n\n\tType your username: ");
  247.         scanf("%s",y);
  248.     }
  249. }
  250.  
  251.  
  252.  
  253. void funcNotif(char x[],char *appPtr) {
  254.     system("cls");
  255.     printf("\n\n\t\t\t ~~ ADMIN'S SCREEN ~~" "\n\n\n\t You have 1 notification." "\n\n\t\tUsername: %s",x);
  256.     do {
  257.         printf("\n\n\t Approve?: ");
  258.         scanf("%s",appPtr);
  259.     }
  260.     while ((strcmp(appPtr,"Yes")!=0)&&(strcmp(appPtr,"No")!=0));
  261. }
  262.  
  263.  
  264.  
  265. void UserToPass(char *Ptr) {
  266.     while  (*Ptr != '\0') {
  267.         *Ptr = toupper( *Ptr );
  268.         Ptr+=2;
  269.     }
  270. }
  271.  
  272.  
  273.  
  274. void funcClScreen(char *clAccessPtr) {
  275.     system("cls");
  276.     printf("\n\n\t\t      Welcome to the Client's Home Page!");
  277.     printf("\n\n\n\t 1)Information");
  278.     printf("\n\n\n\t 2)Order");
  279.     printf("\n\n\n\t 3)Exit");
  280.     do {
  281.         printf("\n\n\n\n\t\t\t     Get access to: ");
  282.         scanf("%s",clAccessPtr);
  283.     }
  284.     while ((strcmp(clAccessPtr,"Information")!=0)&&(strcmp(clAccessPtr,"Exit")!=0));   
  285. }
  286.  
  287.  
  288.  
  289. void funcInfo() {
  290.     int i;
  291.     printf("\n\n\n\t\tPlease complete your personal info: ");
  292.     printf("\n\n\t\t     Name: ");
  293.     scanf(" %s",ClientArray[1]);
  294.     printf("\n\t\t     Surname: ");
  295.     scanf(" %s",ClientArray[2]);
  296.         printf("\n\t\t     Street: ");
  297.     scanf(" %s",ClientArray[3]);
  298.     printf("\n\t\t     Street number: ");
  299.     scanf(" %s",ClientArray[4]);
  300.     printf("\n\t\t     Postal code: ");
  301.     scanf(" %s",ClientArray[5]);
  302.     for (i=0;i<7;i++) {
  303.         printf("\n %s",&ClientArray[i]);
  304.     }
  305. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement