Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <chrono>
- #include <ctime>
- #include <fstream>
- #include <iostream>
- #include <map>
- #include <mutex>
- #include <string>
- #include <thread>
- #include <utility>
- #include <windows.h>
- #include <vector>
- #include <mmsystem.h>
- #include <stdlib.h>
- #pragma comment(lib, "winmm.lib")
- void setcursor(bool visible) // set bool visible = 0 - invisible, bool visible = 1 - visible
- {
- HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
- CONSOLE_CURSOR_INFO lpCursor;
- lpCursor.bVisible = visible;
- lpCursor.dwSize = 20;
- SetConsoleCursorInfo(console, &lpCursor);
- }
- int dir = 4;
- int num = 1;
- int hight = 15;
- int weight = 40;
- #pragma region first
- std::mutex cout_mutex;
- int a = 0; //10-exit 3- sleep
- struct cursor_position
- {
- int x;
- int y;
- };
- void setpos(cursor_position position)
- {
- COORD pos;
- pos.X = position.x;
- pos.Y = position.y;
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
- }
- cursor_position getpos()
- {
- CONSOLE_SCREEN_BUFFER_INFO sbi;
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &sbi);
- return { sbi.dwCursorPosition.X, sbi.dwCursorPosition.Y };
- }
- void setcol(int col)
- {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), col);
- }
- template <typename message_type>
- void write_to_stream(const message_type message,int col, cursor_position position = { -1, -1 })
- {
- std::lock_guard<decltype(cout_mutex)> locker(cout_mutex);
- if (position.x == -1 || position.y == -1)
- {
- std::cout << message;
- return;
- }
- auto prev_pos = getpos();
- setpos(position);
- setcol(col);
- std::cout << message;
- setcol(7);
- setpos(prev_pos);
- }
- void cls(HANDLE hConsole)
- {
- std::lock_guard<decltype(cout_mutex)> locker(cout_mutex);
- COORD coordScreen = { 0, 0 }; // home for the cursor
- DWORD cCharsWritten;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- DWORD dwConSize;
- // Get the number of character cells in the current buffer.
- if (!GetConsoleScreenBufferInfo(hConsole, &csbi))
- return;
- dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
- // Fill the entire screen with blanks.
- if (!FillConsoleOutputCharacter(hConsole, (TCHAR)' ', dwConSize, coordScreen, &cCharsWritten))
- return;
- // Get the current text attribute.
- if (!GetConsoleScreenBufferInfo(hConsole, &csbi))
- return;
- // Set the buffer's attributes accordingly.
- if (!FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
- return;
- // Put the cursor at its home coordinates.
- SetConsoleCursorPosition(hConsole, coordScreen);
- }
- void first_menu(int choice);
- void second_menu(int counter);
- void thrid_menu(int choice, int counter);
- void rules();
- void table_for_menu();
- void paint_the_flovers();
- void easy_english_test();
- void normal_english_test();
- void hard_english_test();
- void dictionary();
- void easy_math_test();
- void normal_math_test();
- void hard_math_test();
- void theory();
- void easy_bio_test();
- void normal_bio_test();
- void hard_bio_test();
- void theory_bio();
- class english
- {
- public:
- void first_english_menu()
- {
- int choice_en = 0, counter_en = 0;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- while (true)
- {
- switch (choice_en)
- {
- case 80:
- {
- counter_en++;
- if (counter_en > 4)
- counter_en = 0;
- break;
- }
- case 72:
- {
- counter_en--;
- if (counter_en < 0)
- counter_en = 4;
- break;
- }
- case 13:
- {
- thrid_english_menu(counter_en);
- break;
- }
- }
- cls(hStdout);
- second_english_menu(counter_en);
- choice_en = _getwch();
- }
- }
- protected:
- void second_english_menu(int choice_en)
- {
- table_for_menu();
- char variant[5][11] = { "Easy", "Normal", "Hard", "Dictionary", "Exit" };
- write_to_stream("MENU",3, { 10, 2 });
- for (int i = 0; i < 5; i++)
- {
- if (i == 0)
- write_to_stream(" ", 7, { 8, 3 + i });
- if (i == choice_en)
- {
- for (int j = 0; j < strlen(variant[i]); j++)
- {
- write_to_stream(" ", 3, { 8+j, 3 + i });
- write_to_stream(variant[i][j], 3,{ 8+j, 3 + i });
- }
- }
- else
- {
- for (int j = 0; j < strlen(variant[i]); j++)
- {
- write_to_stream(" ", 7, { 8+j, 3 + i });
- write_to_stream(variant[i][j], 7, { 8+j, 3 + i });
- }
- }
- write_to_stream("\n",7);
- }
- }
- void thrid_english_menu(int counter_en)
- {
- bool exit = true;
- while (exit)
- {
- switch (counter_en)
- {
- case 0:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- bool exit_0 = true;
- while (exit_0)
- {
- a = 10;
- easy_english_test();
- write_to_stream("\nyou was win easy level\nif you want to exit, press \"escape\"\n",12);
- if (_getwch() == 27)
- {
- exit_0 = false;
- cls(hStdout);
- int choice = 0, counter = 0;
- second_english_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_english_menu();
- }
- else if (_getwch() != 27)
- cls(hStdout);
- a = 0;
- }
- break;
- }
- case 1:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- bool exit_1 = true;
- while (exit_1)
- {
- normal_english_test();
- write_to_stream("normal\nif you want to exit, press \"escape\"\n",7);
- if (_getwch() == 27)
- {
- exit_1 = false;
- cls(hStdout);
- int choice = 0, counter = 0;
- second_english_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_english_menu();
- }
- else if (_getwch() != 27)
- cls(hStdout);
- }
- break;
- }
- case 2:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- bool exit_2 = true;
- while (exit_2)
- {
- hard_english_test();
- write_to_stream("hard\nif you want to exit, press \"escape\"\n",7);
- if (_getwch() == 27)
- {
- exit_2 = false;
- cls(hStdout);
- int choice = 0, counter = 0;
- second_english_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_english_menu();
- }
- else if (_getwch() != 27)
- cls(hStdout);
- }
- break;
- }
- case 3:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- bool exit_3 = true;
- while (exit_3)
- {
- dictionary();
- write_to_stream("dictionary\nif you want to exit, press \"escape\"",7);
- if (_getwch() == 27)
- {
- exit_3 = false;
- int choice = 0, counter = 0;
- cls(hStdout);
- second_english_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_english_menu();
- }
- else if (_getwch() != 27)
- cls(hStdout);
- }
- break;
- }
- case 4:
- {
- exit = false;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- int choice = 0, counter = 0;
- first_menu(choice);
- choice = _getwch();
- cls(hStdout);
- thrid_menu(choice, counter);
- break;
- }
- default:
- break;
- }
- }
- }
- };
- void easy_english_test()
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- std::map<std::string, std::string>m
- {
- {"яблуко","apple"},
- {"лимон","lemon"},
- {"картопля","potato"},
- {"вино","wine"},
- {"м'ясо","meat"}
- };
- std::string arrW[5]= { "яблуко","лимон","картопля","вино","м'ясо" };
- int attempt = 0;
- cls(hStdout);
- while (attempt !=5)
- {
- write_to_stream("uk word: ",7);
- std::string word;
- std::string h_word;
- word = arrW[attempt];
- write_to_stream(word,7);
- auto f = m.find(word);
- write_to_stream("\nEnter transtale: ",7);
- std::cin >> h_word;
- cls(hStdout);
- if (h_word == (*f).second)
- {
- write_to_stream((*f).first, 3);
- write_to_stream(" - ", 12);
- write_to_stream((*f).second, 3);
- write_to_stream("\ncorrect\n", 12);
- }
- else
- {
- write_to_stream("not correct translate, try again\n", 12);
- attempt--;
- }
- attempt++;
- }
- a = 0;
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- }
- void normal_english_test()
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- std::map<std::string, std::string>m
- {
- {"добрий"," kind"},
- {"щедрий" ,"generous"},
- {"скупий", "mean"},
- {"щасливий","chearful"},
- {"нещасний","miserable"},
- {"напружений","tense"},
- {"безтурботний","easy-going"},
- {"сильний","strong"},
- {"слабкий","weak"},
- {"чесний","honest"}
- };
- std::string arrW[10] = { "добрий","щедрий","скупий","щасливий","нещасний","напружений","безтурботний","сильний", "слабкий" ,"чесний" };
- int attempt = 0;
- cls(hStdout);
- while (attempt != 10)
- {
- write_to_stream("uk word: ", 7);
- std::string word;
- std::string h_word;
- word = arrW[attempt];
- write_to_stream(word, 7);
- auto f = m.find(word);
- write_to_stream("\nEnter transtale: ", 7);
- std::cin >> h_word;
- cls(hStdout);
- if (h_word == (*f).second)
- {
- write_to_stream((*f).first, 3);
- write_to_stream(" - ", 12);
- write_to_stream((*f).second, 3);
- write_to_stream("\ncorrect\n", 12);
- }
- else
- {
- write_to_stream("not correct translate, try again\n", 12);
- attempt--;
- }
- attempt++;
- }
- a = 0;
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- }
- void hard_english_test()
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- std::map<std::string, std::string>m
- {
- {"красивий","handsome"},
- {"борода" ,"beard"},
- {"мила", "pretty"},
- {"привабливий","atractive"},
- {"гидкий","ugly"},
- {"ніякий","plain"},
- {"високий","tall"},
- {"стрункий","slim"},
- {"товстий","fat"},
- {"мускулистий","muscular"},
- {"худий","thin"},
- {"жахливо","terribly"},
- {"кістлявий","skinny"},
- {"блідий","pale"},
- {"шрам","scar"}
- };
- std::string arrW[15] = { "красивий","борода","мила","привабливий","гидкий","ніякий","високий","стрункий", "товстий" ,"мускулистий","худий","жахливо","кістлявий","блідий","шрам" };
- int attempt = 0;
- cls(hStdout);
- while (attempt != 15)
- {
- write_to_stream("uk word: ", 7);
- std::string word;
- std::string h_word;
- word = arrW[attempt];
- write_to_stream(word, 7);
- auto f = m.find(word);
- write_to_stream("\nEnter transtale: ", 7);
- std::cin >> h_word;
- cls(hStdout);
- if (h_word == (*f).second)
- {
- write_to_stream((*f).first, 3);
- write_to_stream(" - ", 12);
- write_to_stream((*f).second, 3);
- write_to_stream("\ncorrect\n", 12);
- }
- else
- {
- write_to_stream("not correct translate, try again\n", 12);
- attempt--;
- }
- attempt++;
- }
- a = 0;
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- }
- void dictionary()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- bool exit = true;
- while (exit)
- {
- std::ifstream dictionary_file("dictionary.txt", std::ios_base::in);
- std::vector<std::string>v;
- std::string S;
- if (!dictionary_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(dictionary_file, S))v.push_back(S);
- for (unsigned int i = 0; i < v.size(); i++)
- {
- write_to_stream(v.at(i), 7);
- write_to_stream("\n", 7);
- }
- dictionary_file.close();
- write_to_stream("\nif you want to exit, press \"escape\"", 7);
- if (_getwch() == 27)
- exit = false;
- else if (_getwch() != 27)
- cls(hStdout);
- }
- a = 0;
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- }
- class math
- {
- public:
- void first_math_menu()
- {
- int choice_mt = 0, counter_mt = 0;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- while (true)
- {
- switch (choice_mt)
- {
- case 80:
- {
- counter_mt++;
- if (counter_mt > 4)
- counter_mt = 0;
- break;
- }
- case 72:
- {
- counter_mt--;
- if (counter_mt < 0)
- counter_mt = 4;
- break;
- }
- case 13:
- {
- thrid_math_menu(counter_mt);
- break;
- }
- }
- cls(hStdout);
- second_math_menu(counter_mt);
- choice_mt = _getwch();
- }
- }
- protected:
- void second_math_menu(int choice_mt)
- {
- table_for_menu();
- char variant[5][21] = { "Easy", "Normal", "Hard", "Theory", "Exit" };
- write_to_stream("MENU\n",3, { 10, 2 });
- for (int i = 0; i < 5; i++)
- {
- if (i == 0) write_to_stream("",7,{ 8, 3 + i });
- if (i == choice_mt)
- {
- for (int j = 0; j < strlen(variant[i]); j++)
- {
- write_to_stream(" ", 3, { 8+j, 3 + i });
- write_to_stream(variant[i][j], 3, { 8 + j, 3 + i });
- }
- }
- else
- {
- for (int j = 0; j < strlen(variant[i]); j++)
- {
- write_to_stream(" ", 7, { 8 + j, 3 + i });
- write_to_stream(variant[i][j], 7, { 8 + j, 3 + i });
- }
- }
- write_to_stream("\n", 7);
- }
- }
- void thrid_math_menu(int counter_mt)
- {
- bool exit = true;
- while (exit)
- {
- switch (counter_mt)
- {
- case 0:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- easy_math_test();
- cls(hStdout);
- int choice = 0, counter = 0;
- second_math_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_math_menu();
- break;
- }
- case 1:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- normal_math_test();
- cls(hStdout);
- int choice = 0, counter = 0;
- second_math_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_math_menu();
- break;
- }
- case 2:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- hard_math_test();
- cls(hStdout);
- int choice = 0, counter = 0;
- second_math_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_math_menu();
- break;
- }
- case 3:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- theory();
- cls(hStdout);
- int choice = 0, counter = 0;
- second_math_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_math_menu();
- break;
- }
- case 4:
- {
- exit = false;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- int choice = 0, counter = 0;
- first_menu(choice);
- choice = _getwch();
- cls(hStdout);
- thrid_menu(choice, counter);
- break;
- }
- default:
- break;
- }
- }
- }
- };
- void easy_math_test()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream math_easy_file("math.txt", std::ios_base::in);
- if (!math_easy_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(math_easy_file, S))v.push_back(S);
- for (int i = 56; i < 73; i++)
- {
- if (i == 56 || i == 60 || i == 63 || i == 66 || i == 69 )setcol(12);
- else setcol(7);
- write_to_stream( v.at(i),7);
- write_to_stream("\n", 7);
- }
- math_easy_file.close();
- char arr[5] = { 'Б','В','В','Г','Г'};
- char answer;
- for (int i = 0; i < 5; i++)
- {
- write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
- write_to_stream(i+1, 7);
- std::cin >> answer;
- if (answer == arr[i])
- {
- setcol(12);
- write_to_stream("\ncorrect\n", 12);
- setcol(7);
- }
- else
- {
- setcol(12);
- write_to_stream("mistake\n", 12);
- setcol(7);
- }
- }
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- Sleep(1000);
- a = 0;
- }
- void normal_math_test()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream math_normal_file("math.txt", std::ios_base::in);
- if (!math_normal_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(math_normal_file, S))v.push_back(S);
- for (int i = 73; i < 89; i++)
- {
- if (i == 73 || i == 76 || i == 80 || i == 83 || i == 86)setcol(12);
- else setcol(7);
- write_to_stream(v.at(i), 7);
- write_to_stream("\n", 7);
- }
- math_normal_file.close();
- char arr[5] = { 'В','Б','Б','А','Б' };
- char answer;
- for (int i = 0; i < 5; i++)
- {
- write_to_stream("\nВведіть відповідь (великою буквою) до завдання ", 7);
- write_to_stream(i + 1, 7);
- std::cin >> answer;
- if (answer == arr[i])
- {
- setcol(12);
- write_to_stream("\ncorrect\n", 12);
- setcol(7);
- }
- else
- {
- setcol(12);
- write_to_stream("mistake\n", 12);
- setcol(7);
- }
- }
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- Sleep(1000);
- a = 0;
- }
- void hard_math_test()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream math_normal_file("math.txt", std::ios_base::in);
- if (!math_normal_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(math_normal_file, S))v.push_back(S);
- for (int i = 89; i < 109; i++)
- {
- if (i == 89 || i == 93 || i == 96 || i == 101 || i == 105)setcol(12);
- else setcol(7);
- write_to_stream(v.at(i), 7);
- write_to_stream("\n", 7);
- }
- math_normal_file.close();
- char arr[5] = { 'Г','В','Б','Б','В' };
- char answer;
- for (int i = 0; i < 5; i++)
- {
- write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
- write_to_stream(i + 1, 7);
- std::cin >> answer;
- if (answer == arr[i])
- {
- setcol(12);
- write_to_stream("\ncorrect\n", 12);
- setcol(7);
- }
- else
- {
- setcol(12);
- write_to_stream("mistake\n", 12);
- setcol(7);
- }
- }
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- Sleep(1000);
- a = 0;
- }
- void theory()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- a = 3;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- bool exit = true;
- while (exit)
- {
- std::string S;
- std::vector<std::string>v;
- std::ifstream math("math.txt", std::ios_base::in);
- if (!math.is_open())
- write_to_stream("error\n", 7);
- while (getline(math, S))v.push_back(S);
- for (unsigned int i = 0; i < 53; i++)
- {
- if (i == 0||i==4 || i == 7 || i == 10 || i == 13 || i == 17 || i == 20 || i == 24 || i == 27 || i == 30 || i == 33 || i == 37 || i == 40 || i == 45 || i == 49)setcol(12);
- else setcol(7);
- write_to_stream(v.at(i), 7);
- write_to_stream("\n", 7);
- }
- math.close();
- write_to_stream("\nif you want to exit, press \"escape\"", 7);
- if (_getwch() == 27)
- exit = false;
- else if (_getwch() != 27)
- cls(hStdout);
- }
- a = 0;
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- }
- class biology
- {
- public:
- void first_biology_menu()
- {
- int choice_bio = 0, counter_bio = 0;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- while (true)
- {
- switch (choice_bio)
- {
- case 80:
- {
- counter_bio++;
- if (counter_bio > 4)
- counter_bio = 0;
- break;
- }
- case 72:
- {
- counter_bio--;
- if (counter_bio < 0)
- counter_bio = 4;
- break;
- }
- case 13:
- {
- thrid_biology_menu(counter_bio);
- break;
- }
- }
- cls(hStdout);
- second_biology_menu(counter_bio);
- choice_bio = _getwch();
- }
- }
- protected:
- void second_biology_menu(int choice_bio)
- {
- table_for_menu();
- char variant[5][10] = { "Easy", "Normal", "Hard", "Theory", "Exit" };
- setcol(3);
- write_to_stream(" MENU\n",3, { 10, 2 });
- for (int i = 0; i < 5; i++)
- {
- if (i == 0)
- write_to_stream("",7,{ 8, 3 + i });
- if (i == choice_bio)
- {
- for (int j = 0; j < strlen(variant[i]); j++)
- {
- write_to_stream(" ", 3, { 8 + j, 3 + i });
- write_to_stream(variant[i][j], 3, { 8 + j, 3 + i });
- }
- }
- else
- {
- for (int j = 0; j < strlen(variant[i]); j++)
- {
- write_to_stream(" ", 7, { 8 + j, 3 + i });
- write_to_stream(variant[i][j], 7, { 8 + j, 3 + i });
- }
- }
- write_to_stream("\n", 7);
- }
- }
- void thrid_biology_menu(int counter_bio)
- {
- bool exit = true;
- while (exit)
- {
- switch (counter_bio)
- {
- case 0:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- easy_bio_test();
- cls(hStdout);
- int choice = 0, counter = 0;
- second_biology_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_biology_menu();
- break;
- }
- case 1:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- normal_bio_test();
- cls(hStdout);
- int choice = 0, counter = 0;
- second_biology_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_biology_menu();
- break;
- }
- case 2:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- hard_bio_test();
- cls(hStdout);
- int choice = 0, counter = 0;
- second_biology_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_biology_menu();
- break;
- }
- case 3:
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- theory_bio();
- write_to_stream("if you wante to exit, press escape",7);
- while (_getwch() != 27)
- {
- Sleep(100);
- }
- cls(hStdout);
- int choice = 0, counter = 0;
- second_biology_menu(choice);
- choice = _getwch();
- cls(hStdout);
- first_biology_menu();
- break;
- }
- case 4:
- {
- exit = false;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- int choice = 0, counter = 0;
- first_menu(choice);
- choice = _getwch();
- cls(hStdout);
- thrid_menu(choice, counter);
- break;
- }
- default:
- break;
- }
- }
- }
- };
- void easy_bio_test()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream bio_easy_file("biology.txt", std::ios_base::in);
- if (!bio_easy_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(bio_easy_file, S))v.push_back(S);
- for (int i = 0; i < 26; i++)
- {
- if (i == 0 || i == 6 || i == 11 || i == 16 || i == 21 )setcol(12);
- else setcol(7);
- write_to_stream( v.at(i),7);
- write_to_stream("\n", 7);
- }
- bio_easy_file.close();
- char arr[5] = { 'В','Б','А','А','В'};
- char answer;
- for (int i = 0; i < 5; i++)
- {
- write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
- write_to_stream(i+1, 7);
- std::cin >> answer;
- if (answer == arr[i])
- {
- setcol(12);
- write_to_stream("\ncorrect\n", 12);
- setcol(7);
- }
- else
- {
- setcol(12);
- write_to_stream("mistake\n", 12);
- setcol(7);
- }
- }
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- Sleep(1000);
- a = 0;
- }
- void normal_bio_test()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream bio_normal_file("biology.txt", std::ios_base::in);
- if (!bio_normal_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(bio_normal_file, S))v.push_back(S);
- for (int i = 26; i < 51; i++)
- {
- if (i == 26 || i == 31 || i == 36 || i == 41 || i == 46)setcol(12);
- else setcol(7);
- write_to_stream(v.at(i), 7);
- write_to_stream("\n", 7);
- }
- bio_normal_file.close();
- char arr[5] = { 'А','Б','В','Б','В' };
- char answer;
- for (int i = 0; i < 5; i++)
- {
- write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
- write_to_stream(i + 1, 7);
- std::cin >> answer;
- if (answer == arr[i])
- {
- setcol(12);
- write_to_stream("\ncorrect\n", 12);
- setcol(7);
- }
- else
- {
- setcol(12);
- write_to_stream("mistake\n", 12);
- setcol(7);
- }
- }
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- Sleep(1000);
- a = 0;
- }
- void hard_bio_test()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream bio_hard_file("biology.txt", std::ios_base::in);
- if (!bio_hard_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(bio_hard_file, S))v.push_back(S);
- for (int i = 51; i < 76; i++)
- {
- if (i == 51 || i == 56 || i == 61 || i == 67 || i == 71)setcol(12);
- else setcol(7);
- write_to_stream(v.at(i), 7);
- write_to_stream("\n", 7);
- }
- bio_hard_file.close();
- char arr[5] = { 'В','В','Г','А','А' };
- char answer;
- for (int i = 0; i < 5; i++)
- {
- write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
- write_to_stream(i + 1, 7);
- std::cin >> answer;
- if (answer == arr[i])
- {
- setcol(12);
- write_to_stream("\ncorrect\n", 12);
- setcol(7);
- }
- else
- {
- setcol(12);
- write_to_stream("mistake\n", 12);
- setcol(7);
- }
- }
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- Sleep(1000);
- a = 0;
- }
- void theory_bio()
- {
- a = 3;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream bio_normal_file("biology.txt", std::ios_base::in);
- if (!bio_normal_file.is_open())
- write_to_stream("error\n", 7);
- while (getline(bio_normal_file, S))v.push_back(S);
- for (int i = 77; i < 94; i++)
- {
- write_to_stream(v.at(i), 7);
- write_to_stream("\n", 7);
- }
- bio_normal_file.close();
- SetConsoleCP(866);
- SetConsoleOutputCP(866);
- Sleep(1000);
- a = 0;
- }
- void first_menu(int choice)
- {
- table_for_menu();
- char variants[5][10] = { "English", "Math", "Biology", "Rules", "Exit" };
- write_to_stream(" MENU\n",3, { 10, 2 });
- for (int i = 0; i < 5; i++)
- {
- if (i == 0) write_to_stream(" " ,7, { 8, 3 + i });
- if (i == choice)
- {
- for (int j = 0; j < strlen(variants[i]); j++)
- {
- write_to_stream("", 7);
- write_to_stream(variants[i][j], 3, { 8+j, 3 + i });
- }
- }
- else
- {
- for (int j = 0; j < strlen(variants[i]); j++)
- {
- write_to_stream("", 7);
- write_to_stream(variants[i][j], 7, { 8+j, 3 + i });
- }
- }
- write_to_stream("\n", 7);
- }
- }
- void second_menu(int counter)
- {
- switch (counter)
- {
- case 0:
- {
- english en;
- en.first_english_menu();
- break;
- }
- case 1:
- {
- math mt;
- mt.first_math_menu();
- break;
- }
- case 2:
- {
- biology bio;
- bio.first_biology_menu();
- break;
- }
- case 3:
- {
- rules();
- break;
- }
- case 4:
- {
- a = 10;
- exit(0);
- break;
- }
- default:
- break;
- }
- }
- void thrid_menu(int choice, int counter)
- {
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- while (true)
- {
- switch (choice)
- {
- case 80:
- {
- counter++;
- if (counter > 4)
- counter = 0;
- break;
- }
- case 72:
- {
- counter--;
- if (counter < 0)
- counter = 4;
- break;
- }
- case 13:
- {
- second_menu(counter);
- break;
- }
- }
- cls(hStdout);
- first_menu(counter);
- choice = _getwch();
- }
- }
- void rules()
- {
- a = 3;
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- cls(hStdout);
- std::string S;
- std::vector<std::string>v;
- std::ifstream rules_file("rules_file.txt", std::ios_base::in);
- if (!rules_file.is_open())
- write_to_stream( "error\n",7);
- while (getline(rules_file, S))v.push_back(S);
- for (unsigned int i = 0; i < v.size(); i++)
- {
- if (i == 0)setcol(12);
- else setcol(3);
- write_to_stream(v.at(i), 3);
- write_to_stream("\n", 7);
- }
- setcol(7);
- rules_file.close();
- write_to_stream("\nif you want to exit, press \"escape\"",7);
- while (_getwch() != 27)Sleep(100);
- a = 0;
- }
- void table_for_menu()
- {
- setcol(7);
- //----------верхня лінія
- write_to_stream((char)201,7, { 1, 0 });
- for (int i = 1; i < 26; i++)
- {
- write_to_stream((char)205,7, { 1 + i, 0 });
- }
- write_to_stream((char)187,7, { 27, 0 });
- //-----------нижня лінія
- write_to_stream((char)200,7, { 1, 9 });
- for (int i = 1; i < 26; i++)
- {
- write_to_stream((char)205,7, { 1 + i, 9 });
- }
- write_to_stream((char)188,7, { 27, 9 });
- // paint_the_flovers();
- //--------права лінія
- for (int i = 1; i < 9; i++)
- {
- write_to_stream((char)186,7, { 27, 0 + i });
- }
- //---------ліва лінія
- for (int i = 1; i < 9; i++)
- {
- write_to_stream((char)186,7, { 1, 0 + i });
- }
- }
- void paint_the_flovers()
- {
- int counter = 0;
- int arr[340] = { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, 3,
- 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 1,
- 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1,
- 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3,
- 3, 3, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1,
- 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
- constexpr int x_start = 50;
- constexpr int y_start = 2;
- while (a!=10)
- {
- if (a == 3)
- {
- while (a == 3)
- {
- Sleep(1000);
- }
- }
- int x_offset = 0;
- int y_offset = 0;
- for (int i = 0; i < 340; i++)
- {
- if (i % 20 == 0)
- {
- ++y_offset;
- x_offset = 0;
- }
- switch (arr[i])
- {
- case 1:
- {
- // setpos(50 + i, y + counter);
- // std::cout << " ";
- write_to_stream(" ",7, { x_start + x_offset, y_start + y_offset });
- break;
- }
- case 2:
- {
- // setpos(50 + i, y + counter);
- // std::cout << (char)178 << (char)178;
- write_to_stream((char)178, 15,{ x_start + x_offset, y_start + y_offset });
- break;
- }
- case 3:
- {
- // setpos(50 + i, y + counter);
- if (rand() % 2 + 1 == 1) write_to_stream((char)178, 4,{ x_start + x_offset, y_start + y_offset });
- else if (rand() % 2 + 1 == 2) write_to_stream((char)178,12, { x_start + x_offset, y_start + y_offset });
- else
- write_to_stream((char)178, 13, { x_start + x_offset, y_start + y_offset });
- // std::cout << (char)178 << (char)178;
- break;
- }
- default:
- break;
- }
- ++x_offset;
- }
- }
- }
- #pragma endregion
- struct car
- {
- int x;
- int y;
- }car[100];
- void table_for_game()
- {
- setcol(7);
- //----------верхня лінія
- write_to_stream((char)201, 7, { 1, 0 });
- for (int i = 1; i < 40; i++)
- {
- write_to_stream((char)205, 7, { 1 + i, 0 });
- }
- write_to_stream((char)187, 7, { 27, 0 });
- //-----------нижня лінія
- write_to_stream((char)200, 7, { 1, 9 });
- for (int i = 1; i < 40; i++)
- {
- write_to_stream((char)205, 7, { 1 + i, 9 });
- }
- write_to_stream((char)188, 7, { 27, 9 });
- // paint_the_flovers();
- //--------права лінія
- for (int i = 1; i < 15; i++)
- {
- write_to_stream((char)186, 7, { 27, 0 + i });
- }
- //---------ліва лінія
- for (int i = 1; i < 15; i++)
- {
- write_to_stream((char)186, 7, { 1, 0 + i });
- }
- }
- class asteroids_drow
- {
- public:
- int x, y;
- void New()
- {
- x = rand() % weight;
- y = rand() % weight;
- }
- void drow_aster()
- {
- setcol(rand() % 15);
- std::cout << "#";
- }
- }aster[3];
- void Tick()
- {
- if (dir == 0) car[0].y += 1;
- if (dir == 1) car[0].x -= 1;
- if (dir == 2) car[0].x += 1;
- if (dir == 3) car[0].y -= 1;
- for (int i = 0; i < 10; i++)
- {
- if ((car[0].x == aster[i].x) && (car[0].y == aster[i].y))
- {
- aster[i].New();
- car[i].x = car[i - 1].x;
- car[i].y = car[i - 1].y;
- }
- }
- if (car[0].x > weight)car[0].x = 0;
- if (car[0].y > hight)car[0].y = 0;
- if (car[0].x < 0)car[0].x = weight;
- if (car[0].y < 0)car[0].y = hight;
- }
- void MyKeyboard(int key, int a, int b)
- {
- switch (key)
- {
- case 101: dir = 0; break;
- case 102: dir = 2; break;
- case 100: dir = 1; break;
- case 103: dir = 3; break;
- }
- }
- void game()
- {
- table_for_game();
- for (int i = 0; i < 2; i++)
- {
- aster[i].drow_aster();
- }
- }
- int main()
- {
- setcursor(0);
- //game();
- PlaySound(TEXT("Mendelson.wav"), NULL, SND_FILENAME | SND_ASYNC);
- srand(time(0));
- table_for_menu();
- HANDLE hStdout;
- hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- std::thread th(paint_the_flovers);
- int choice = 0, counter = 0;
- first_menu(choice);
- choice = _getwch();
- cls(hStdout);
- thrid_menu(choice, counter);
- _getwch();
- th.join();
- system("pause>nul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement