#ifndef _ADDRESS_H
#define _ADDRESS_H
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
class book
{
public:
book();//默认无参构造
void AddIn();
void AddId();
void AddName();
void AddMobile();
void AddTelephone();
void Addaddr();
void Print();
string& getName();
string& getMobile();
string& getTele();
string& getaddr();
int& getid();
private:
string name; //姓名
string mobile; //手机
string telephone; //电话号码
string addr; //地址
int id;
};
#endif
#include "address.h"
book::book()
{
}
void book::AddIn()
{
this->AddId();
this->AddName();
int flag = 1;
while(flag)
{
try
{
this->AddMobile();
}
catch(int error)
{
if(error == 10001)
{
cout << "电话号码不足11位" <<endl;
flag = 1;
}
else if(error == 10002)
{
flag = 0;
}
}
}
this->AddTelephone();
this->Addaddr();
}
void book::AddId()
{
cout<<"请输入您的序号"<< endl;
cin >>this->id;
}
void book::AddName()
{
cout<<"请输入您的姓名"<<endl;
cin>>this->name;
}
void book::AddMobile()
{
int ERROR = 10001,SUCCESS =10002;
cout<<"请输入您的手机号码"<<endl;
cin>>this->mobile;
if(this->mobile.length()!= 11)
throw ERROR;
else
throw SUCCESS;
}
void book::AddTelephone()
{
cout<<"请输入您的住宅