case 'A':
case 'a':addRecord();break;
case 'F':
case 'f':queryRecord();break;
case 'D':
case 'd':displayRecords();break;
case 'L':
case 'l':loadRecords();break;
case 'C':
case 'c':clear();break;
case 'S':
case 's':saveRecords();break;
case 'Q':
case 'q':quit();break;
}
handleMenu();
信息显示:
void AddressBook::displayRecords(){
cout<<"姓名"<<SPACE<<"电话"<<endl;
AddressList::saveRecords(cout);
cout<<"一共找到"<<size()<<"个对象。"<<endl;
cout<<"1"<<SPACE<<"返回"<<endl;
cout<<"2"<<SPACE<<"修改"<<endl;
cout<<"3"<<SPACE<<"删除"<<endl;
switch(menuSelect()){
case '1':break;
case '2':{
if(!size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要修改第几个?"<<"1~"<<size()<<endl;
int i;
cin>>i;
if(i<1||i>size()){
break;
}
Record *prec=new Record;
cout<<"姓名:"<<'\n'<<"电话:"<<'\n';
cin>>prec;
Iterator it=recList.begin();
while(i!=1){
it++;
i--;
}
editRecord(prec,it);
}break;
case'3':{
if(!size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要删除第几个?"<<"1~"<<size()<<endl;
int i;
cin>>i;
if(i<1||i>size()){
break;
信息添加:
void AddressBook::addRecord(){
string name,tel;
cout << "\n输入名字: ";
cin >> name;
cout << "输入电话: ";
cin >> tel;
Record* temp=new Record;
temp->name=name;
temp->tel=tel;
AddressList::addRecord(temp);
cout<<"是否继续(Y/N)"<<endl;
switch(menuSelect()){
case '1':addRecord();break;
case '2':break;
}
信息的查找:
void AddressBook::queryRecord(){
cout<<"1"<<SPACE<<"按姓名查找"<<endl;
cout<<"2"<<SPACE<<"按电话查找"<<endl;
int type=-1;
string patten;
switch(menuSelect()){
case '1':{
type=0;
cout<<"请输入姓名"<<endl;
cin>>patten;
}break;
case '2':{
type=1;
www.youerw.com
Iterator it=begin();
list<Iterator> li;
cout<<"姓名"<<SPACE<<"电话"<<endl;
while((it=findRecord(patten,type,it))!=end()){
cout<<*it;
li.push_back(it);
it++;
}
cout<<"一共找到"<<li.size()<<"个对象。"<<endl;
cout<<"1"<<SPACE<<"返回"<<endl;
cout<<"2"<<SPACE<<"修改"<<endl;
cout<<"3"<<SPACE<<"删除"<<endl;
switch(menuSelect()){
case'1':break;
case'2':{
if(!li.size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要修改第几个?"<<"1~"<<li.size()<<endl;
int i; 594
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页