Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AlenaKursach.cpp: главный файл проекта.
- #include "stdafx.h"
- #include "iostream"
- #include "fstream"
- #include "string"
- using namespace System;
- using namespace std;
- struct Resort
- {
- string PlaceOfResort;
- string CityOfResort;
- int PriceOfResort;
- int StayPrice;
- };
- struct Access
- {
- string login;
- string password;
- };
- Resort InformationAboutResort;
- Access LogAndPassInfo;
- int CountOfResort = 0;
- int StartMenu();
- int UserAccess;
- void AddResortBook();
- void ReadResortBook();
- void SelectSort();
- void ClearResortBook();
- int LoginAndPassword();
- void ChangeUserAccess();
- int main(array<System::String ^> ^args)
- {
- setlocale( 0, "Rus" );
- if ( LoginAndPassword() == 1 )
- {
- do
- {
- } while ( StartMenu() != 2 );
- }
- else
- {
- cout << "Неверное имя польователя или пароль!";
- }
- return 0;
- }
- int StartMenu()
- {
- int UserSelect;
- cout << "Добро пожаловать в справочник курортов! Что бы вы хотели сделать?" << endl;
- cout << "1) Добавление курорта в книгу!" << endl;
- cout << "2) Вывод справочника на экран." << endl;
- cout << "3) Вывод сортированного справочника " << endl;
- cout << "4) Очистить курортную книгу." << endl;
- cout << "5) Изменить данные входа." << endl;
- cout << "6) Выход из программы." << endl;
- cout << "Введите ваш выбор: ";
- cin >> UserSelect;
- switch ( UserSelect )
- {
- case 1:
- {
- AddResortBook();
- return 1;
- break;
- }
- case 2:
- {
- ReadResortBook();
- return 1;
- break;
- }
- case 3:
- {
- SelectSort();
- return 1;
- break;
- }
- case 4:
- {
- ClearResortBook();
- return 1;
- break;
- }
- case 5:
- {
- ChangeUserAccess();
- return 1;
- break;
- }
- case 6:
- {
- cout << "Досвидания, спасибо за использование программы!" << endl;
- return 2;
- break;
- }
- default:
- {
- cout << "Попробуйте еще раз!" << endl;
- StartMenu();
- return 1;
- break;
- }
- }
- }
- void AddResortBook()
- {
- fstream WorkWithFile;
- WorkWithFile.open( "ResortBook.txt", ios::app );
- cout << " Функция добавляет курорт в список" << endl;
- cout << "Введите наименование курорта" << endl;
- cin >> InformationAboutResort.PlaceOfResort;
- cout << endl;
- cout << "Введите город курорта: ";
- cin >> InformationAboutResort.CityOfResort;
- cout << endl;
- cout << "Введите стоимость поездки ";
- cin >> InformationAboutResort.PriceOfResort;
- cout << endl;
- cout << "Введите стоимость проживания ";
- cin >> InformationAboutResort.StayPrice;
- cout << endl;
- WorkWithFile.write( (char*)&InformationAboutResort, sizeof( InformationAboutResort ) );
- cout << "Данные занесены в книгу!" << endl;
- WorkWithFile.close();
- };
- void ReadResortBook()
- {
- fstream WorkWithFile;
- WorkWithFile.open( "ResortBook.txt", ios::in );
- do
- {
- WorkWithFile.read( (char*)&InformationAboutResort, sizeof( InformationAboutResort ) );
- if ( WorkWithFile.eof() )
- break;
- cout << InformationAboutResort.PlaceOfResort << " " << InformationAboutResort.CityOfResort << " " << InformationAboutResort.PriceOfResort << " " << InformationAboutResort.StayPrice << endl;
- } while ( true );
- WorkWithFile.close();
- };
- void SelectSort()
- {
- cout << "a";
- };
- void ClearResortBook()
- {
- fstream WorkWithFile;
- WorkWithFile.open( "ResortBook.txt", ios::out );
- WorkWithFile.clear();
- WorkWithFile.close();
- };
- int LoginAndPassword()
- {
- fstream WorkWithFile;
- WorkWithFile.open( "UserAccess.txt", ios::in );
- WorkWithFile.read( (char*)&LogAndPassInfo, sizeof( LogAndPassInfo ) );
- string UserName, Password;
- cout << " Добро пожаловать в программу, введите имя пользователя и пароль для входа в систему! " << endl;
- cout << "Имя пользователя: ";
- cin >> UserName;
- cout << endl;
- cout << "Пароль: ";
- cin >> Password;
- if ( UserName == LogAndPassInfo.login && Password == LogAndPassInfo.password )
- {
- return 1;
- }
- else
- {
- return 2;
- }
- }
- void ChangeUserAccess()
- {
- fstream WorkWithFile;
- WorkWithFile.open( "UserAccess.txt", ios::out );
- //WorkWithFile.clear();
- cout << "Введите новое имя пользователя: ";
- cin >> LogAndPassInfo.login;
- cout << endl;
- cout << "Введите новый пароль: ";
- cin >> LogAndPassInfo.password;
- cout << endl;
- WorkWithFile.write( (char*)&LogAndPassInfo, sizeof ( LogAndPassInfo ) );
- WorkWithFile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement