Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void List::showSearch(string search_line, int searchType)
- {
- Hotel *temp = Head;
- size_t found;
- ns = 0;
- string number_s , cost_s;
- vector<string> searchThere;
- if (searchType == 1) {
- while (temp)
- {
- number_s = to_string(temp->id);
- searchThere.push_back(number_s);
- temp = temp->Next;
- }
- }
- else if (searchType == 2) {
- while (temp)
- {
- searchThere.push_back(temp->fname);
- temp = temp->Next;
- }
- }
- else if (searchType==3) {
- while (temp)
- {
- cost_s = to_string(temp->cost);
- searchThere.push_back(cost_s);
- temp=temp->Next;
- }
- }
- bool search_success=false;
- string findThere;
- int i=0;
- temp=Head;
- while (temp) {
- findThere=searchThere[i];
- found=findThere.find(search_line);
- if (found != std::string::npos)
- search_success=true;
- temp=temp->Next;
- i++;
- }
- if (search_success==true) {
- temp=Head;
- i=0;
- cout << "\t\t\t\t\t\tБД. " << endl;
- cout << "--------------------------------------------------------------------------------------------------------------------" << endl;
- cout << "| НК | Имя | Фамилия | Дата въезда | Дата выезда | Номер телефона | Стоимость | Индекс |" << endl;
- cout << "--------------------------------------------------------------------------------------------------------------------" << endl;
- while (temp) {
- findThere=searchThere[i];
- found=findThere.find(search_line);
- if (found != std::string::npos) {
- cout << "|" << setw(4) << temp->id << " |";
- printf(" %11s | %14s | %15s | %12s | %15s |",
- temp->name, temp->fname, temp->date_1, temp->date_2, temp->phoneNumber);
- cout << setw(11) << temp->cost << " | " << setw(3) << ns + 1 << " |" << endl;
- cout << "--------------------------------------------------------------------------------------------------------------------" << endl;
- ns++; search_success=true;
- }
- temp=temp->Next; i++;
- }
- cout << "\t\t\t\t\t\t\t\t\t\t\tНайдено Объектов: " << ns << endl;
- }
- else cout<<"Поиск не дал результатов..."<<endl;
- }
- void List::Search()
- {
- if (n == 0) cout << "БД пуста..." << endl;
- int searchType;
- string search_line;
- cout << "Поиск по: 1. Номеру комнаты, 2. Фамилии, 3.Стоимости : "; cin >> searchType;
- if (searchType<=0 || searchType>3) cout<<"Неверный выбор.";
- else {
- cout << "Введите строку поиска: "; cin >> search_line;
- showSearch(search_line, searchType);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement