Advertisement
s3nnou

Untitled

May 11th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.61 KB | None | 0 0
  1. void filesLoadingsSavingsAndChecking (listFirstFile *& headFirstFile, listFirstFile *& tailFirstFile, int &sizeOf_FirstFile,listSecondFile *& headSecondFile, listSecondFile *& tailSecondFile, int &sizeOf_SecondFile) {
  2.     int c;
  3.     string fileName;
  4.     bool isOpened = false;
  5.     bool isDone1 = false, isDone2 = false;
  6.     bool escape = false;
  7.  
  8.     do {
  9.  
  10.         do {
  11.             cout << "\n\tВыберите действие:\n\t\t1. Cоздать новый Файл 1 \n\t\t2. Загрузить Файл 1\n\t\t3. Завершить работу и выйти" << endl;
  12.             dumbChecker(c);
  13.             switch (c) {
  14.             case 1: {
  15.                 isDone1 = true;
  16.                 break;
  17.             }
  18.             case 2: {
  19.                 cout << "\t\tВведите имя сохраненного Файла 1:\n> " << endl;
  20.                 cin >> fileName;
  21.  
  22.                 while (!isOpened) {
  23.  
  24.                     ifstream fin(fileName + ".txt");
  25.                     if (fin.is_open())
  26.                     {
  27.                         while (!fin.eof())
  28.                         {
  29.                             listFirstFile *temp = new listFirstFile;
  30.                             if (headFirstFile == NULL) {
  31.                                 temp->prev = NULL;
  32.                                 temp->next = NULL;
  33.                                 fin >> temp->lectureHall;
  34.                                 fin >> temp->PCSerial;
  35.                                 fin >> temp->pulpit;
  36.                                 fin >> temp->surname;
  37.                                 fin >> temp->name;
  38.                                 fin >> temp->patronymic;
  39.                                 headFirstFile = temp;
  40.                                 tailFirstFile = temp;
  41.                                 sizeOf_FirstFile++;
  42.                             }
  43.                             else {
  44.                                 tailFirstFile->next = temp;
  45.                                 fin >> temp->lectureHall;
  46.                                 fin >> temp->PCSerial;
  47.                                 fin >> temp->pulpit;
  48.                                 fin >> temp->surname;
  49.                                 fin >> temp->name;
  50.                                 fin >> temp->patronymic;
  51.                                 temp->next = NULL;
  52.                                 temp->prev = tailFirstFile;
  53.                                 tailFirstFile = temp;
  54.                                 sizeOf_FirstFile++;
  55.                             }
  56.                         }
  57.                         isOpened = true;
  58.                         fin.close();
  59.                     }
  60.                 }
  61.                 isDone1 = true;
  62.                 break;
  63.             }
  64.             case 3: {
  65.                 return;
  66.             }
  67.             default: {
  68.                 cout << "Введенно некорректное действие. Повторите попытку.\a" << endl;
  69.                 system("pause");
  70.                 system("cls");
  71.             }
  72.             }
  73.  
  74.  
  75.         } while (!isDone1);
  76.  
  77.         isOpened = false;
  78.  
  79.         do {
  80.             cout << "\n\tВыберите действие:\n\t\t1. Cоздать новый Файл 2 \n\t\t2. Загрузить Файл 2\n\t\t3. Шаг назад" << endl;
  81.             dumbChecker(c);
  82.             switch (c) {
  83.             case 1: {
  84.                 isDone2 = true;
  85.                 break;
  86.             }
  87.             case 2: {
  88.                 cout << "\t\tВведите имя сохраненного Файла 2:\n> " << endl;
  89.                 cin >> fileName;
  90.  
  91.                 while (!isOpened) {
  92.  
  93.                     ifstream fin(fileName + ".txt");
  94.                     if (fin.is_open())
  95.                     {
  96.                         while (!fin.eof())
  97.                         {
  98.                             listSecondFile *temp = new listSecondFile;
  99.                             if (headSecondFile == NULL) {
  100.                                 temp->prev = NULL;
  101.                                 temp->next = NULL;
  102.                                 fin >> temp->PCSerial;
  103.                                 fin >> temp->RAM;
  104.                                 fin >> temp->HDD;
  105.                                 headSecondFile = temp;
  106.                                 tailSecondFile = temp;
  107.                                 sizeOf_SecondFile++;
  108.                             }
  109.                             else {
  110.                                 tailSecondFile->next = temp;
  111.                                 fin >> temp->PCSerial;
  112.                                 fin >> temp->RAM;
  113.                                 fin >> temp->HDD;
  114.                                 temp->next = NULL;
  115.                                 temp->prev = tailSecondFile;
  116.                                 tailSecondFile = temp;
  117.                                 sizeOf_SecondFile++;
  118.                             }
  119.                         }
  120.                         isOpened = true;
  121.                         fin.close();
  122.                     }
  123.                 }
  124.                 isDone2 = true;
  125.                 break;
  126.             }
  127.             case 3: {
  128.                 cout << "a";
  129.                 escape = true;
  130.                 break;
  131.             }
  132.             default: {
  133.                 cout << "Введенно некорректное действие. Повторите попытку.\a" << endl;
  134.                 system("pause");
  135.                 system("cls");
  136.             }
  137.             }
  138.            
  139.         } while ( (!isDone2) || (!escape) );
  140.  
  141.     } while (!isDone1 && !isDone2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement