通信录管理系统设计C++源代码 第6页
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;
}
Iterator it=recList.begin();
while(i!=1){
it++;
i--;
}
removeRecord(it);
}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;
cout<<"请输入电话号码"<<endl;
cin>>patten;
}break;
}
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;
www.751com.cncase'2':{
if(!li.size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要修改第几个?"<<"1~"<<li.size()<<endl;
int i;
cin>>i;
Record *prec=new Record;
cout<<"姓名:"<<'\n'<<"电话:"<<'\n';
cin>>prec;
list<Iterator>::const_iterator it=li.begin();
while(i!=1){
it++;
i--;
}
editRecord(prec,*it);
}break;
case'3':{
if(!li.size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要删除第几个?"<<"1~"<<li.size()<<endl;
int i;
cin>>i;
list<Iterator>::const_iterator it=li.begin();
while(i!=1){
it++;
i--;
}
removeRecord(*it);
}break;
}
}
void AddressBook::saveRecords(){
cout<<"1"<<SPACE<<"使用默认文件名。"<<endl;
cout<<"2"<<SPACE<<"使用自定义文件名。"<<endl;
cout<<"3"<<SPACE<<"返回"<<endl;
switch(menuSelect()){
case '1':{
ofstream file("default",ios::app);
AddressList::saveRecords(file);
file.close();
}break;
case '2':{
cout<<"请输入您定义的文件名:"<<endl;
string fname;
cin>>fname;
ofstream file(fname.c_str(),ios::app);
AddressList::saveRecords(file);
file.close();
}break; 上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
通信录管理系统设计C++源代码 第6页下载如图片无法显示或论文不完整,请联系qq752018766