Advertisement
octavio123

codenotcomplete

Apr 8th, 2020
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.95 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #define MAX 100
  5. typedef struct {
  6.     char Title[30]; // title of movie
  7.     char UCPNumber[12]; // ????
  8.     int quantity; //quantity of tickets
  9.     double price; //price of the movie
  10. }MOVIES; //name of the struct
  11.  
  12.          
  13. void NewMovie(MOVIES* dvd, int size); // will hold tempmovie if it return a new UCP
  14. void TempMovie(MOVIES* dvd, int size);
  15. int FindMovie(MOVIES* dvd, int size, char UCPNumber[12]);
  16.  
  17.  
  18.  
  19. int main(void)
  20. {
  21.     char Title[30]; // title of movie
  22.     char UCPNumber[12]; // ????
  23.     int quantity; //quantity of tickets
  24.     double price; //price of the movie
  25.     int size = 0, idx = 0, quit = 0;
  26.     char choose;
  27.     choose = 0;
  28.     MOVIES dvd[MAX];
  29.    
  30.  
  31.     do{
  32.         printf("\n\n\t\tChoose a action.\n\n");
  33.         printf("\t(A)dd a New Movie\n");
  34.         printf("\t(C)hange a Movie's Information\n");
  35.         printf("\t(D)elete a Movie\n");
  36.         printf("\t(L)ist All Movies \n");
  37.         printf("\t(Q)uit \n");
  38.         printf("\ttype the letter required to do such action:");
  39.         scanf("%c", &choose);
  40.         switch (choose)
  41.         {
  42.         case'A':
  43.         case 'a':
  44.         {
  45.             TempMovie(&dvd, size);
  46.             size++;
  47.         }
  48.         break;
  49.         case'C':
  50.         case'c':
  51.         {
  52.             printf("\n\tYou chose Change a Movie's Information\n");
  53.         }
  54.         break;
  55.         case'D':
  56.         case'd':
  57.         {
  58.             printf("\n\tYou chose Delete a Movie\n");
  59.         }
  60.         break;
  61.         case'L':
  62.         case'l':
  63.         {
  64.         }
  65.         break;
  66.         case'Q':
  67.         case'q':
  68.         {
  69.             printf("\n\tYou chose To QUIT\n");
  70.             quit = 1;
  71.         }
  72.         break;
  73.  
  74.         default:
  75.         {
  76.             printf("\nyou chose a wrong character\n");
  77.  
  78.         }
  79.         break;
  80.         }
  81.         system("cls");
  82.         choose = 0;
  83.         //check if UCP is equal
  84.         FindMovie(dvd, size, UCPNumber);
  85.     } while (quit < 1);
  86.  
  87.    
  88.    
  89.  
  90.    
  91. }
  92.  
  93.  
  94. void TempMovie(MOVIES* dvd)
  95. {
  96.    
  97.     getchar();
  98.     printf("\ngive me the Title for the new movie:  ");
  99.     gets(&dvd->Title);
  100.     printf("\ngive me the UCP/SKU for the movie %s : ", dvd->Title);
  101.     gets(&dvd->UCPNumber);
  102.     printf("\ngive me the quantity for the movie %s : ", dvd->Title);
  103.     scanf("%d", &dvd->quantity);
  104.     printf("\ngive me the price for the movie %s : ", dvd->Title);
  105.     scanf("%d", &dvd->price);
  106.    
  107.    
  108. }
  109.  
  110. int FindMovie(MOVIES * dvd, int size, char UCPNumber[12]) //wrong
  111. //int FindMovie(dvdlist* find, int j, char code[12])
  112. {
  113.     int result;
  114.  
  115.  
  116.     int i, new = 0, old =0;
  117.     for (int i = 0; i <= size; i++)
  118.     {
  119.         result = strcmp((dvd + i)->whathere, UCPNumber);
  120.         if (result == 0)
  121.         {
  122.             new = 0;
  123.             return new;
  124.         }
  125.         else
  126.         {
  127.             old = -1;
  128.             return old;
  129.         }
  130.  
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement