void resultSearch(const LodgingList & lodginglist, SFilter & sf, Member & member) { LodgingList llresult; LodgingList ll = lodginglist; int i = 1; int size = ll.getSize(); if(size > 0) { Room r; Lodging l = ll.getFirstLodging(); RoomList rl = l.getRoomList(); RoomList rldel; fileIO::loadBookLodging(rldel, l.getLNumber(), sf.getYear(), sf.getMonth(), sf.getDay(), sf.getPeriod()); int delsize = rldel.getSize(); int j = 1; int money = 2000000000; if(rl.getSize() != delsize) { if(delsize > 0) rl.delRoom(rldel.getFirstRoom().getRNumber()); while(delsize > j++) rl.delRoom(rldel.getNextRoom().getRNumber()); int rlsize = rl.getSize(); j = 1; if(rlsize > 0) { r = rl.getFirstRoom(); if(r.getPersonMax() >= sf.getPerson() && money > r.calcPrice(sf.getPerson())) money = r.calcPrice(sf.getPerson()); } while(rlsize > j) { r = rl.getNextRoom(); if(r.getPersonMax() >= sf.getPerson() && money > r.calcPrice(sf.getPerson())) money = r.calcPrice(sf.getPerson()); j++; } l.setSMoney(money); if(money != 2000000000) llresult.addLodging(l); } } while(size > i) { Room r; Lodging l = ll.getNextLodging(); RoomList rl = l.getRoomList(); RoomList rldel; fileIO::loadBookLodging(rldel, l.getLNumber(), sf.getYear(), sf.getMonth(), sf.getDay(), sf.getPeriod()); int delsize = rldel.getSize(); int j = 1; int money = 2000000000; if(rl.getSize() != delsize) { if(delsize > 0) rl.delRoom(rldel.getFirstRoom().getRNumber()); while(delsize > j++) rl.delRoom(rldel.getNextRoom().getRNumber()); int rlsize = rl.getSize(); j = 1; if(rlsize > 0) { r = rl.getFirstRoom(); if(r.getPersonMax() >= sf.getPerson() && money > r.calcPrice(sf.getPerson())) money = r.calcPrice(sf.getPerson()); } while(rlsize > j) { r = rl.getNextRoom(); if(r.getPersonMax() >= sf.getPerson() && money > r.calcPrice(sf.getPerson())) money = r.calcPrice(sf.getPerson()); j++; } l.setSMoney(money); if(money != 2000000000) llresult.addLodging(l); } i++; } llresult = sort(llresult, CR_MONEY); cout << " ****************************************************************************** " << endl << " * 숙 박 예 약 프 로 그 램 * " << endl << " ****************************************************************************** " << endl << endl << setw(7) << sf.getYear() << "년 " << setw(2) << sf.getMonth() << "월 " << setw(2) << sf.getDay() << "일부터 " << sf.getPeriod() << "일간 예약 가능한 " << sf.getPerson() << "명 이상의 방입니다." << endl << endl << " 번호 / 숙소 이름 / 위치 / 등급 / 가격" << endl; int sizellr = llresult.getSize(); int k = 1; if(sizellr > 0) { Lodging l = llresult.getFirstLodging(); cout << setw(9) << 1 << " / " << setw(25) << l.getName() << " / "; switch(l.getLocation()) { case 1: cout << " 서울 "; break; case 2: cout << " 부산 "; break; case 3: cout << " 제주도 "; break; default: cout << " "; } cout << " / "; for(int x = 0; x < 5; x++) { if(x < l.getStar()) cout << "★"; else cout << " "; } cout << " /" << setw(11) << l.getSMoney() << endl; } while(sizellr > k) { Lodging l = llresult.getNextLodging(); cout << setw(9) << k + 1 << " / " << setw(25) << l.getName() << " / "; switch(l.getLocation()) { case 1: cout << " 서울 "; break; case 2: cout << " 부산 "; break; case 3: cout << " 제주도 "; break; default: cout << " "; } cout << " / "; for(int x = 0; x < 5; x++) { if(x < l.getStar()) cout << "★"; else cout << " "; } cout << " /" << setw(11) << l.getSMoney() << endl; k++; } cin.ignore(1024, '\n'); cout << endl << " 확인할 번호를 입력하세요." << endl << "입력(1~" << sizellr << "):"; int y = keyIO::inputNumList(1, sizellr); Lodging lresult = llresult.searchIndexLodging(y-1); reservation::viewDetailLodging(lresult, sf, member); }
int checkBook(const Lodging & lodging) { Room r; RoomList rltemp; RoomList rl = lodging.getRoomList(); int size = rl.getSize(); Calendar cal = Calendar(true); int x = 1; cout << " ****************************************************************************** " << endl << " 숙 박 업 소 관 리 프 로 그 램 " << endl << " ****************************************************************************** " << endl << endl; cout << setw(15) << ""; int m, d; for( int plus = 0; plus < 7 ; plus++) //1주 분량의 날짜 { m = cal.getMonth(); d = cal.getDay(); cout << setw(2) << m << "/" << setw(2) << d << " "; cal.addOneDay(); } cout << endl; cout << "------------------------------------------------------------" <<endl; if(size > 0) { cal = Calendar(true); r = rl.getFirstRoom(); cout << setw(11) << r.getRNumber() << "호| "; for ( int plus = 0 ; plus < 7 ; plus ++) { Room b; int k; fileIO::loadBookLodging(rltemp, r.getLNumber(), cal.getYear(), cal.getMonth(), cal.getDay(), 1); b = rltemp.searchRoom(r.getRNumber()); k = b.getRNumber(); if (k == -1) cout << " O "; else cout << " X "; cal.addOneDay(); } cout << endl; } while ( x < size ) { cal = Calendar(true); r = rl.getNextRoom(); cout << setw(11) << r.getRNumber() << "호| "; for(int plus = 0; plus < 7; plus++) { Room b; int k; fileIO::loadBookLodging(rltemp, r.getLNumber(), cal.getYear(), cal.getMonth(), cal.getDay(), 1); b = rltemp.searchRoom(r.getRNumber()); k = b.getRNumber(); if (k == -1) cout << " O "; else cout << " X "; cal.addOneDay(); } x++; cout << endl; } cal = Calendar(true); x = 1; cout << endl << " 오늘의 예약 | 인원 | 기간 | 연 락 처 | 이 름 " << endl << "------------------------------------------------------------" <<endl; if(size > 0) { r = rl.getFirstRoom(); cout << setw(11) << r.getRNumber() << "호| "; int k; Member m = fileIO::getBookUser(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()); k = m.getMNumber(); if (k == -1) cout << " 오늘의 예약이 없습니다."; else cout << setw(4) << m.getSPerson() << " | " << setw(4) << m.getSPeriod() << " | " << setw(16) << m.getTelephone() << " | " << m.getName(); cout << endl; } while ( x < size ) { r = rl.getNextRoom(); cout << setw(11) << r.getRNumber() << "호| "; Room b; int k; Member m = fileIO::getBookUser(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()); k = m.getMNumber(); if (k == -1) cout << " 오늘의 예약이 없습니다."; else cout << setw(4) << m.getSPerson() << " | " << setw(4) << m.getSPeriod() << " | " << setw(16) << m.getTelephone() << " | " << m.getName(); x++; cout << endl; } x = 1; cout << endl << " 오늘의 룸서비스 : "; if(size > 0) { r = rl.getFirstRoom(); if(fileIO::getBookRoomStatus(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()) == 1) cout << r.getRNumber() << "호, "; } while ( x < size ) { r = rl.getNextRoom(); if(fileIO::getBookRoomStatus(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()) == 1) cout << r.getRNumber() << "호, "; x++; } cout << endl; keyIO::getch(); return M_MENU; }
int searchRoom( LodgingList & lodginglist, Member & member) { string condition; cout<<"search condition"<<endl<<"0:finish"<<endl <<"1:호텔명"<<endl <<"2:지역"<<endl <<"3:등급"<<endl <<"4:최대 인원"<<endl <<"5:가격"<<endl <<"6:모든 호텔"<<endl <<"7:다중 조건 검색"<<endl <<"8:날짜, 기간, 인원"<<endl <<"검색 조건을 입력 하세요.(0~8):"<<endl; int Lnumber; // 숙박업소 고유번호 string Name; // 숙박업소의 이름 int Location; // 숙박업소의 위치 string Address; // 숙박업소의 주소 int Star; // 숙박업소의 등급 string Tel; // 숙박업소의 전화번호1 string Cell; // 숙박업소의 전화번호2 RoomList Roomlist;// 방 리스트 int Cost;int ss;//서치를 카운팅 int de=1; while(de) { getline(cin,condition);//search condition int cod; cod = atoi(condition.c_str()); Lodging l= lodginglist.getFirstLodging(); switch(cod) { case 0:de=0;break; case 1:ss=0; { cout<<"호텔명"<<endl; string Sname;int i1 = 1; getline(cin,Sname); Name=l.getName(); int size1=lodginglist.getSize(); //searching with condition Name if(Sname==Name) { Location=l.getLocation(); Address=l.getAddress(); Tel=l.getTelephone(); Cell=l.getCellphone(); Cost=l.getSMoney();Star=l.getStar(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } while(i1<size1) { l=lodginglist.getNextLodging(); Name=l.getName(); if(Sname==Name) { Location=l.getLocation(); Address=l.getAddress(); Tel=l.getTelephone(); Cell=l.getCellphone();Star=l.getStar(); Cost=l.getSMoney(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소 :"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } i1++; } if(ss==0){cout<<"No result"<<endl;} string t; getline(cin,t);return 3; }break; //location case 2:{ss=0; cout<<"지역"<<endl; int sLocation;int i2 = 1; string slc; getline(cin,slc); sLocation=atoi(slc.c_str()); Location=l.getLocation();int size2=lodginglist.getSize(); if(sLocation==Location) { Name=l.getName(); Address=l.getAddress();Star=l.getStar(); Tel=l.getTelephone(); Cell=l.getCellphone(); Cost=l.getSMoney(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } while(i2<size2) { l=lodginglist.getNextLodging(); Location=l.getLocation(); if(sLocation==Location) { Name=l.getName(); Address=l.getAddress(); Tel=l.getTelephone();Star=l.getStar(); Cell=l.getCellphone(); Cost=l.getSMoney(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } i2++; } if(ss==0){cout<<"No result"<<endl;} string t; getline(cin,t); return 3; }break; //grade Star case 3: {ss=0; cout<<"등급"<<endl; int Sstar;int i3 = 1;int size3=lodginglist.getSize();string sst; getline(cin,sst); Sstar=atoi(sst.c_str()); Star=l.getStar(); if(Sstar<=Star) { Name=l.getName(); Location=l.getLocation(); Address=l.getAddress(); Tel=l.getTelephone(); Cell=l.getCellphone(); Cost=l.getSMoney(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } while(i3<size3) { l=lodginglist.getNextLodging(); Name=l.getName(); if(Sstar==Star) {Location=l.getLocation(); Address=l.getAddress();Name=l.getName(); Tel=l.getTelephone(); Cell=l.getCellphone(); Cost=l.getSMoney(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } i3++; } if(ss==0){cout<<"No result"<<endl;} string t; getline(cin,t); return 3; }break; //roomcapacity case 4:{ss=0; int Size; int i4; i4=1; int size4; size4=lodginglist.getSize(); cout<<"room capacity"<<endl;int Capacity; int sCapacity;int Price;int Rnumber;string scp; getline(cin,scp); sCapacity= atoi(scp.c_str()); //fist lodging Lodging L=lodginglist.getFirstLodging(); RoomList rl; rl= L.getRoomList(); Room R; R=rl.getFirstRoom(); Capacity=R.getPersonMax(); if(sCapacity<=Capacity) { Name=L.getName(); Location=L.getLocation(); Address=L.getAddress(); Tel=L.getTelephone(); Cell=l.getCellphone(); Star=L.getStar(); Capacity=R.getPersonMax(); cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<<"Tell:"<<Tel<<"\tCell:"<<Cell<<endl<<"등급:"<<Star<<endl<<"최대 인원:"<<Capacity<<endl; } int rsize=L.getRoomList().getSize(); int mr0=1; while(mr0<rsize) { rl=L.getRoomList(); R=rl.getNextRoom(); if(sCapacity<=Capacity) { Name=L.getName(); Location=L.getLocation(); Address=L.getAddress(); Tel=L.getTelephone(); Cell=l.getCellphone(); Star=L.getStar(); Capacity=R.getPersonMax();ss++; cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl <<"Tel:"<<Tel<<"\tCell:"<<Cell<<endl<<"등급:"<<Star<<endl<<"최대 인원:"<<Capacity<<endl; } mr0++; } while(i4<size4) { L=lodginglist.getNextLodging(); RoomList rl=L.getRoomList(); R=rl.getFirstRoom(); Capacity=R.getPersonMax(); if(sCapacity<=Capacity) { Name=L.getName(); Location=L.getLocation(); Address=L.getAddress(); Tel=L.getTelephone(); Cell=l.getCellphone(); Star=L.getStar(); Capacity=R.getPersonMax();ss++; cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl <<"Tel:"<<Tel<<"\tCell:"<<Cell<<endl<<"등급:"<<Star<<endl<<"최대 인원:"<<Capacity<<endl; } while(mr0<rsize) { rl=L.getRoomList(); R=rl.getNextRoom(); if(sCapacity<=Capacity) { Name=L.getName(); Location=L.getLocation(); Address=L.getAddress(); Tel=L.getTelephone(); Cell=l.getCellphone(); Star=L.getStar(); Capacity=R.getPersonMax();ss++; cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl <<"Tel:"<<Tel<<"\tCell:"<<Cell<<endl<<"등급:"<<Star<<endl<<"최대 인원:"<<Capacity<<endl; } mr0++; } i4++; }if(ss==0)cout<<"NO result!"<<endl; string t;getline(cin,t);return 3; } break; case 5: {ss=0; cout<<"가격"<<endl; string ccc;int i5 = 1;int size5=lodginglist.getSize();int sCost; getline(cin,ccc); Cost=l.getSMoney(); if(sCost>=Cost) { Name=l.getName(); Location=l.getLocation(); Address=l.getAddress(); Tel=l.getTelephone(); Cell=l.getCellphone(); Star=l.getStar(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } while(i5<size5) { l=lodginglist.getNextLodging(); Name=l.getName(); if(sCost>=Cost) { Location=l.getLocation(); Address=l.getAddress();Name=l.getName(); Tel=l.getTelephone(); Cell=l.getCellphone(); Star=l.getStar(); Lnumber=l.getLNumber();ss++; cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역 :"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; } i5++; } if(ss==0){cout<<"No result"<<endl;} string t;getline(cin,t);return 3; } break; case 6: {ss=0;cout<<"all lodging"<<endl; Lodging l = lodginglist.getFirstLodging(); Name=l.getName(); Location=l.getLocation(); Address=l.getAddress(); Tel=l.getTelephone(); Cell=l.getCellphone(); Cost=l.getSMoney();Star=l.getStar(); Lnumber=l.getLNumber(); cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; int i6 = 1;int size6=lodginglist.getSize(); while(i6<size6) { Lodging l=lodginglist.getNextLodging(); Name=l.getName(); Location=l.getLocation(); Address=l.getAddress(); Tel=l.getTelephone(); Cell=l.getCellphone();Star=l.getStar(); Cost=l.getSMoney(); Lnumber=l.getLNumber(); cout<<Lnumber<<"."<<endl<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<< "주소:"<<Address<<endl<<"가격:"<<Cost<<"Telephone:"<<Tel<<endl<<"Cellphone:"<<Cell<<endl; i6++; }string t;getline(cin,t);return 3;}break; case 7: { ss=0; string Locationq,capacityq,costq; string smName; int Capacity; int smLocation,smCost,smCapacity; cout<<"condition"<<endl<<"검색할 호텔명:";getline(cin,smName);cout<<"검색할 지역:";getline(cin,Locationq); cout<<"상한 가격:";getline(cin,costq);cout<<"수용 인원:";getline(cin,capacityq); if(Locationq=="") smLocation=0; else smLocation=atoi(Locationq.c_str()); if(costq=="") smCost=0; else smCost=atoi(costq.c_str()); if(capacityq=="") smCapacity=0; else smCapacity=atoi(capacityq.c_str()); cout<<"검색결과=============================="<<endl; Lodging L=lodginglist.getFirstLodging(); int lsize=lodginglist.getSize(); int li=1; Name=L.getName();Location=L.getLocation();Cost=L.getSMoney(); RoomList rl; rl= L.getRoomList(); Room R; R=rl.getFirstRoom(); Capacity=R.getPersonMax(); if(smName.empty() || smName==Name) { if(smLocation==0 || smLocation==Location) { if(smCost==0|| smCost>=Cost) { if(smCapacity==0 || smCapacity<=Capacity) { Tel=L.getTelephone(); Cell=L.getCellphone(); Address=L.getAddress();ss++; cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<<"주소:"<<Address<<endl<<"가격:"<<Cost<<endl <<"최대 인원:"<<Capacity<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone"<<Cell<<endl; } } } } int rsize=L.getRoomList().getSize(); int ri=1; while(ri<rsize) { rl=L.getRoomList(); R=rl.getNextRoom(); if(smName=="" || smName==Name) { if(smLocation==0 || smLocation==Location) { if(smCost==0 || smCost>=Cost) { if(smCapacity==0 || smCapacity<=Capacity) { Tel=L.getTelephone(); Cell=L.getCellphone(); Address=L.getAddress();ss++; cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<<"주소:"<<Address<<endl<<"가격:"<<Cost<<endl <<"최대 인원:"<<Capacity<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone"<<Cell<<endl; } } } } ri++;; } while(li<lsize) { L=lodginglist.getNextLodging(); RoomList rl=L.getRoomList(); R=rl.getFirstRoom(); Capacity=R.getPersonMax(); if(smName=="" || smName==Name) { if(smLocation==0 || smLocation==Location) { if(smCost==0 || smCost>=Cost) { if(smCapacity==0 || smCapacity<=Capacity) { Tel=L.getTelephone(); Cell=L.getCellphone(); Address=L.getAddress();ss++; cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<<"주소:"<<Address<<endl<<"가격:"<<Cost<<endl <<"최대 인원:"<<Capacity<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone"<<Cell<<endl; } } } } while(ri<rsize) { rl=L.getRoomList(); R=rl.getNextRoom(); if(smName=="" || smName==Name) { if(smLocation==0 || smLocation==Location) { if(smCost==0 || smCost>=Cost) { if(smCapacity==0 || smCapacity<=Capacity) { Tel=L.getTelephone(); Cell=L.getCellphone(); Address=L.getAddress();ss++; cout<<"호텔:"<<Name<<endl<<"지역:"<<Location<<endl<<"주소:"<<Address<<endl<<"가격:"<<Cost<<endl <<"최대 인원:"<<Capacity<<endl<<"Telephone:"<<Tel<<endl<<"Cellphone"<<Cell<<endl; } } } } ri++; } li++; } if(ss==0)cout<<"NO result!"<<endl; string t;getline(cin,t); return 3; }break; case 8: searchRoom2(lodginglist, member); break; default:{} break; } } return 3; }
int viewLodging(Member & member) //예약확인 { system("clear"); RoomList rl; int memnum; memnum = member.getMNumber(); fileIO::loadBookUser(rl, memnum); Room a = rl.getFirstRoom(); int size = rl.getSize(); int y,m,d,p, r, l, person; int x = 1; cout << "******************************************************************************" <<endl; cout << " 나의 예약 현황" <<endl; cout << "******************************************************************************" <<endl; if( size > 0 ) { y = a.getMYear(); m = a.getMMonth(); d = a.getMDay(); p = a.getMPeriod(); r = a.getRNumber(); person = a.getMPerson(); l = a.getLNumber(); cout << " Hotel Number : " << l <<endl; cout << " RNUMBER : " << r << endl; cout << " HEAD COUNT : " << person << endl; cout << " DATE : "<< y << " " << m << " " << d << "부터 " << p << "일 동안" << endl; cout << "----------------------------------------------------------------------------" <<endl; } while ( x < size ) { Room b = rl.getNextRoom(); y = b.getMYear(); m = b.getMMonth(); d = b.getMDay(); p = b.getMPeriod(); r = b.getRNumber(); l = a.getLNumber(); cout << " Hotel Number : " << l <<endl; cout << " RNUMBER : " << r << endl; cout << " HEAD COUNT : " << person << endl; cout << " DATE : "<< y << " " << m << " " << d << "부터 " << p << "일 동안" << endl; cout << "----------------------------------------------------------------------------" <<endl; x++; } cin.ignore(1024, '\n'); }