Advertisement
Maligosus

main.cpp

Nov 13th, 2019
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.19 KB | None | 0 0
  1. main.cpp
  2.  
  3. #include "student.h"
  4.  
  5.  
  6. enum MenuItem
  7. {
  8.     MENU_KEY_1=1,
  9.     MENU_KEY_2,
  10.     MENU_KEY_3,
  11.     MENU_KEY_4,
  12.     MENU_KEY_5,
  13. };
  14.  
  15. void ShowMenuItems()
  16. {
  17.     std::cout << "1.Добавить студента в базу" << std::endl;
  18.     std::cout << "2.Вывести всех студентов в базе" << std::endl;
  19.     std::cout << "3.Удалить студента по фамилии(удаляет первого попавшегося)" << std::endl;
  20.     std::cout << "4.Вывести двоечников" << std::endl;
  21.     std::cout << "5.Выход" << std::endl;
  22. }
  23.  
  24. int main(int argc, char* argv[])
  25. {
  26.     BaseQueue<Student>* studentList = nullptr;
  27.     SearchStatus status = SEARCH_QUEUE_EMPTY;
  28.     bool isExit = false;
  29.     bool isEmpty = true;
  30.     int iMenuItem = 0;
  31.     int iStudentCount = 0;
  32.     SetConsoleCP(1251);
  33.     SetConsoleOutputCP(1251);
  34.     char buffer[STUDENT_MAX_FULLNAME_LENGTH];
  35.     Student inputStudent;
  36.     do {
  37.         system("cls");
  38.         ShowMenuItems();
  39.         std::cout << "Пункт меню";
  40.         while (!(std::cin >> iMenuItem))
  41.         {
  42.             std::cin.clear();
  43.             while (std::cin.get() != '\n');
  44.             {
  45.                 std::cout << "Ошибка, неккоректный ввод" << std::endl;
  46.                 std::cout << "Пункт меню";
  47.             }
  48.         }
  49.         switch (iMenuItem)
  50.         {
  51.             case MENU_KEY_1:
  52.                 system("cls");
  53.                 std::cout << iStudentCount + 1 << "-й студент" << std::endl;
  54.                 InputStudentDataFromConsole(inputStudent);
  55.                 InsertToQueue(&studentList, inputStudent);
  56.                 iStudentCount++;
  57.                 std::cout << "Успешно" << std::endl;
  58.                 system("PAUSE");
  59.                 break;
  60.             case MENU_KEY_2:
  61.                 system("cls");
  62.                 if (studentList)
  63.                     system("PAUSE");
  64.                     ShowAllStudentsInfo(studentList, status);
  65.                 switch (status) {
  66.                     case SEARCH_QUEUE_EMPTY:
  67.                         std::cout << "Список пуст" << std::endl;
  68.                         break;
  69.                 }  
  70.                 system("PAUSE");
  71.                 break;
  72.             case MENU_KEY_3:
  73.                 system("cls");
  74.                 std::cout << "Введите фамилию:";
  75.                 std::cin.ignore();
  76.                 std::cin.getline(buffer, STUDENT_MAX_FULLNAME_LENGTH);
  77.                 DelStudentByName(&studentList, buffer, status);
  78.                 switch (status)
  79.                 {
  80.                     case SEARCH_QUEUE_EMPTY:
  81.                         std::cout << "Список пуст" << std::endl;
  82.                         break;
  83.                     case SEARCH_QUEUE_NOT_FINDED:
  84.                         std::cout << "Студент с такой фамилией не найден" << std::endl;
  85.                         break;
  86.                     case SEARCH_QUEUE_SUCCESS:
  87.                         std::cout << "Запись успешно удалена" << std::endl;
  88.                         iStudentCount--;
  89.                         break;
  90.                 }
  91.                 system("PAUSE");
  92.                 break;
  93.             case MENU_KEY_4:
  94.                 system("cls");
  95.                 std::cout << "Двоечники" << std::endl;
  96.                 ShowAllStudentsByMark(studentList, 2, status);
  97.                 switch (status)
  98.                 {
  99.                     case SEARCH_QUEUE_EMPTY:
  100.                         std::cout << "Список студентов пуст" << std::endl;
  101.                         break;
  102.                     case SEARCH_QUEUE_NOT_FINDED:
  103.                         std::cout << "Двоечники не найдены" << std::endl;
  104.                         break;
  105.                     case SEARCH_QUEUE_SUCCESS:
  106.                         std::cout << "Двоечники найдены" << std::endl;
  107.                         break;
  108.  
  109.                 }
  110.                 system("PAUSE");
  111.                 break;
  112.             case MENU_KEY_5:
  113.                 isExit = true;
  114.                 break;
  115.         }
  116.     } while (!isExit);
  117.  
  118.     return 0;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement