Advertisement
AIwinter

🦴🦴 теория систем 1 лаба

Nov 7th, 2022
1,541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.58 KB | None | 0 0
  1. Uses Crt;
  2.  
  3. type
  4.   Actors = Record
  5.     ID_A: word;
  6.     Name_A: string[18];
  7.     Fam_A: string[18];
  8.     DofB: string[8];
  9.     Roles: byte; {1 - главная, 2 - второстепенная, 3 - массовка}
  10.     Gender: boolean;
  11.   end;
  12.  
  13.   Films = Record
  14.     ID_F: word;
  15.     ID_A: word;
  16.     Name_F: string[20];
  17.     Duration: string[6];
  18.     Date: string[8];
  19.   end;
  20.  
  21. var
  22.   FV1: file of Actors;
  23.   ActorsBP: Actors;
  24.  
  25.   FV2: file of Films;
  26.   FilmsBP: Films;
  27.  
  28.   temp: longword;
  29. const
  30.   ActorsName = 'Actors.uwu';
  31.   FilmsName = 'Films.uwu';
  32.   Yes = 'YyУу';
  33.  
  34. procedure Open;
  35. begin
  36.   Assign(FV1, ActorsName);
  37.   Assign(FV2, FilmsName);
  38.  
  39.   if not FileExists(ActorsName) then ReWrite(FV1)
  40.   else ReSet(FV1);
  41.  
  42.   if not FileExists(FilmsName) then ReWrite(FV2)
  43.   else ReSet(FV2);
  44. end;
  45.  
  46. procedure Close;
  47. begin
  48.   Close(FV1);
  49.   Close(FV2);
  50. end;
  51.  
  52. procedure Add;
  53. begin
  54.   var
  55.   input: string;
  56. begin
  57.   if (FileSize(FV1) > 0) then
  58.  
  59.   begin
  60.     Seek(FV1, FileSize(FV1) - 1);
  61.     Read(FV1, ActorsBP);
  62.     ActorsBP.ID_A := ActorsBP.ID_A + 1;
  63.   end
  64.   else ActorsBP.ID_A := 0;
  65.  
  66.   repeat
  67.     Write('Имя актера: ');
  68.     Readln(input);
  69.     until (input.Length <= 18) and (input <> ''.ToString());
  70.     ActorsBP.Name_A := input;
  71.    
  72.   repeat
  73.     Write('Фамилия актера: ');
  74.     Readln(input);
  75.     until (input.Length <= 18) and (input <> ''.ToString());
  76.     ActorsBP.Fam_A := input;
  77.    
  78.   repeat
  79.     Write('Дата рождения: ');
  80.     Readln(input);
  81.     input.Replace('.', '')
  82.     until (input.Length = 8) and longword.TryParse(input, temp);
  83.     ActorsBP.DofB := input;
  84.    
  85.    repeat
  86.      Write('Роль: (1 - главная; 2 - второстепенная; 3 - массовка)');
  87.      Readln(input);
  88.      until (input.Length = 1) and (input <> ''.ToString()) and (input); {нужно сравнить, равен ли инпут 1/2/3}
  89.      ActorsBP.Roles := input;
  90.      
  91.    repeat
  92.      Write('Пол: (M of F)');
  93.      Readln(input);
  94.      
  95.      
  96.      end;
  97. end;
  98.  
  99. procedure List;
  100. begin
  101. end;
  102.  
  103. procedure Menu;
  104. var
  105.   input: string;
  106. begin
  107.   Write('Введите "help" для списка команд. Введите команду: ');
  108.   while input<>'1' do
  109.   begin
  110.     ReadLn(input);
  111.     case input of
  112.       'help':
  113.         WriteLn('1 - выйти' + NewLine + '2 - добавить данные в таблицу'
  114.                     + NewLine + '3 - вывести таблицу Актеров');
  115.       '2': Add;
  116.       '3': List;
  117.     end;
  118.   end;
  119.  
  120. end;
  121.  
  122. begin
  123.   Open;
  124.   Menu;
  125.   Close;
  126. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement