Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <fstream>
- //#include <cstdlib>
- //#include <cctype>
- #include <Windows.h>
- using namespace std;
- string path1 = "vocabulary_rus.txt";
- string path2 = "vocabulary_eng.txt";
- ifstream fin;
- ofstream fout1;
- ofstream fout2;
- char ch;
- int stateX; //мини-меню
- string word, word_fn;
- int con = 1; //переменная для главного меню
- vector <string> vector1;
- class menu {
- protected:
- int state = 0;
- virtual bool init() = 0;
- virtual int button() = 0;
- virtual void print() = 0;
- };
- class MainMenu : public menu{
- public:
- virtual bool init() { return 0; }
- virtual void print() {
- system("cls");
- cout << "Выберите язык/Choose language " << endl;
- cout << "____________________________" << endl;
- cout << "(1) Русский" << endl;
- cout << "(2) English" << endl;
- cout << "(0) Выход/Exit" << endl;
- }
- virtual int button() {
- cin >> state;
- return state;
- }
- };
- class RusVoc : public menu {
- public:
- virtual bool init() {
- fin.open(path1);
- if (!fin.is_open())
- {
- cout << "Ошибка считывания!" << endl;
- return 1;
- }
- return 0;
- }
- virtual void print() {
- system("cls");
- cout << "Русский словарь" << endl;
- cout << "____________________________" << endl;
- cout << "(1) Добавить новое слово" << endl;
- cout << "(2) Найти слово" << endl;
- cout << "(3) Вывести весь словарь" << endl;
- cout << "(4) Узнать о слове больше в переводчике" << endl;
- cout << "(0) Выход в меню" << endl;
- }
- virtual int button() {
- cin >> state;
- return state;
- }
- };
- class EngVoc : public menu {
- public:
- virtual bool init() {
- fin.open(path2);
- if (!fin.is_open())
- {
- cout << "Ошибка считывания!" << endl;
- return 1;
- }
- return 0;
- }
- virtual void print() {
- system("cls");
- cout << "English vocabulary" << endl;
- cout << "____________________________" << endl;
- cout << "(1) Add a new word" << endl;
- cout << "(2) Find the word" << endl;
- cout << "(3) Display the entire dictionary" << endl;
- cout << "(4) Check out more about the word on translator" << endl;
- cout << "(0) Exit to menu" << endl;
- }
- virtual int button() {
- cin >> state;
- return state;
- }
- };
- int MianMenu_start();
- int RusMenu_start();
- int EngMenu_start();
- MainMenu Main;
- EngVoc EngMenu;
- RusVoc RusMenu;
- int MianMenu_start() {
- Main.print();
- switch (Main.button())
- {
- case 1:
- RusMenu_start();
- return 1;
- break;
- case 2:
- EngMenu_start();
- return 2;
- break;
- case 0:
- return 0;
- break;
- default:
- cout << " Ошибка ввода!" << endl;
- return -1;
- break;
- }
- }
- int RusMenu_start() {
- RusMenu.init();
- RusMenu.print();
- switch (RusMenu.button()) {
- case 1:
- cin >> word;
- fout2 << word;
- fout2 << "\n";
- fin.close();
- return 1;
- break;
- case 2:
- //поиск через функцию find()
- return 2;
- break;
- case 3:
- while (fin.get(ch))
- {
- cout << ch;
- }
- return 3;
- break;
- case 4:
- cout << "https://translate.google.com/?hl=ru#view=home&op=translate&sl=auto&tl=en&text=", word; cout << endl;
- return 4;
- break;
- case 0:
- MianMenu_start();
- return 0;
- break;
- default:
- cout << " Ошибка ввода!" << endl;
- return -1;
- break;
- }
- }
- int EngMenu_start() {
- EngMenu.init();
- EngMenu.print();
- switch (EngMenu.button()) {
- case 1:
- cin >> word;
- fout2 << word;
- fout2 << "\n";
- fin.close();
- return 1;
- break;
- case 2:
- //поиск через функцию find()
- return 2;
- break;
- case 3:
- while (fin.get(ch))
- {
- cout << ch;
- }
- return 3;
- break;
- case 4:
- cout << "https://translate.google.com/?hl=ru#view=home&op=translate&sl=auto&tl=en&text=", word; cout << endl;
- return 4;
- break;
- case 0:
- MianMenu_start();
- return 0;
- break;
- default:
- cout << " Ошибка ввода!" << endl;
- return -1;
- break;
- }
- }
- int main()
- {
- setlocale(LC_ALL, "ru");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251); //кодировка вывода на консоль;
- MianMenu_start();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement