Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main.cpp
- #include "student.h"
- enum MenuItem
- {
- MENU_KEY_1=1,
- MENU_KEY_2,
- MENU_KEY_3,
- MENU_KEY_4,
- MENU_KEY_5,
- };
- void ShowMenuItems()
- {
- std::cout << "1.Добавить студента в базу" << std::endl;
- std::cout << "2.Вывести всех студентов в базе" << std::endl;
- std::cout << "3.Удалить студента по фамилии(удаляет первого попавшегося)" << std::endl;
- std::cout << "4.Вывести двоечников" << std::endl;
- std::cout << "5.Выход" << std::endl;
- }
- int main(int argc, char* argv[])
- {
- BaseQueue<Student>* studentList = nullptr;
- SearchStatus status = SEARCH_QUEUE_EMPTY;
- bool isExit = false;
- bool isEmpty = true;
- int iMenuItem = 0;
- int iStudentCount = 0;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- char buffer[STUDENT_MAX_FULLNAME_LENGTH];
- Student inputStudent;
- do {
- system("cls");
- ShowMenuItems();
- std::cout << "Пункт меню";
- while (!(std::cin >> iMenuItem))
- {
- std::cin.clear();
- while (std::cin.get() != '\n');
- {
- std::cout << "Ошибка, неккоректный ввод" << std::endl;
- std::cout << "Пункт меню";
- }
- }
- switch (iMenuItem)
- {
- case MENU_KEY_1:
- system("cls");
- std::cout << iStudentCount + 1 << "-й студент" << std::endl;
- InputStudentDataFromConsole(inputStudent);
- InsertToQueue(&studentList, inputStudent);
- iStudentCount++;
- std::cout << "Успешно" << std::endl;
- system("PAUSE");
- break;
- case MENU_KEY_2:
- system("cls");
- if (studentList)
- system("PAUSE");
- ShowAllStudentsInfo(studentList, status);
- switch (status) {
- case SEARCH_QUEUE_EMPTY:
- std::cout << "Список пуст" << std::endl;
- break;
- }
- system("PAUSE");
- break;
- case MENU_KEY_3:
- system("cls");
- std::cout << "Введите фамилию:";
- std::cin.ignore();
- std::cin.getline(buffer, STUDENT_MAX_FULLNAME_LENGTH);
- DelStudentByName(&studentList, buffer, status);
- switch (status)
- {
- case SEARCH_QUEUE_EMPTY:
- std::cout << "Список пуст" << std::endl;
- break;
- case SEARCH_QUEUE_NOT_FINDED:
- std::cout << "Студент с такой фамилией не найден" << std::endl;
- break;
- case SEARCH_QUEUE_SUCCESS:
- std::cout << "Запись успешно удалена" << std::endl;
- iStudentCount--;
- break;
- }
- system("PAUSE");
- break;
- case MENU_KEY_4:
- system("cls");
- std::cout << "Двоечники" << std::endl;
- ShowAllStudentsByMark(studentList, 2, status);
- switch (status)
- {
- case SEARCH_QUEUE_EMPTY:
- std::cout << "Список студентов пуст" << std::endl;
- break;
- case SEARCH_QUEUE_NOT_FINDED:
- std::cout << "Двоечники не найдены" << std::endl;
- break;
- case SEARCH_QUEUE_SUCCESS:
- std::cout << "Двоечники найдены" << std::endl;
- break;
- }
- system("PAUSE");
- break;
- case MENU_KEY_5:
- isExit = true;
- break;
- }
- } while (!isExit);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement