该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
void VIP::show( Node *v)
{
no(v);
char *a=VIP::sex(v);
std::cout<
<< "会员姓名: "<< node.item.num[1]<< endl
<< "性别: "<< sex(v)<
<< "手机号码: "<< node.item.num[2]<< endl
<< "储值账户: "<< node.item.mony<< endl
<< "积分账户: "<< node.item.gra<< endl<
}
VIP::Node * VIP::Find(int i)
{
int a=0;
char n[11];
char *ite;
switch(i){
case 0:ite="卡号:";break;
case 1:ite="姓名:";break;
case 2:ite="手机号码:";break;}
cout<
cin.getline(n,10);
Node *temp=head;
while(temp!=NULL)
{
if(strstr(temp->item.num[i],n)!=NULL)
{
show(temp);
a++;
temp=temp->next;
continue;
}
else if(temp->next==NULL&&a==0)
{
cout<< "没有这个会员,重新输入(q 退出):"<< endl;
cin.getline(n,10);
if(!strcmp(n,"q"))
break;
temp=head;
continue;
}
temp=temp->next;
}
return NULL;
}
void VIP::Save()
{
if(!Items())
{
cout<< "没有会员..太失败了.."<< endl;
return ;
}
Node *v=InTheVIP();
if(v!=NULL)
{
int i;
cout<< "请输入要储存的金额:\n";
cin>> i;
while(getchar()!='\n');
v->item.mony += i;
show(v);
}
}
void VIP::Con()
{
if(!Items())
{
cout<< "没有会员..太失败了.."<< endl;
return ;
}
Node *v=InTheVIP();
if(v==NULL)return;
int i;
cout<< "请输入要消费的金额:\n";
while(cin>> i&& i!=0)
{
while(getchar()!='\n');
if(i<=v->item.mony)
{
cout<< "请输入密码:";
char n[10];
while(cin >>n&&strcmp(v->item.num[3],n))
{
if(strcmp(n,"q"))
return;
cout<< "输入错误,请重新输入(q退出)";
}
v->item.mony -= i;
v->item.gra += i;
cout<< "扣款成功"<
show(v);
break;
}
else
cout<< "余额不足,请重新输入(0 退出)"<
}
}
void VIP::showall()
{
if(!Items())
{
cout<< "没有会员.太失败了.."<< endl;
return;
}
printf("%-15s%-10s%-15s%-15s%-15s\n", "会员卡号", "姓名", "手机号码", "储值账户", "积分账户");
for(Node *temp=head;temp!=NULL;temp=temp->next)
{
printf("%-15s%-10s%-15s%-15.1f%-15.1f\n",
temp->item.num[0]
,temp->item.num[1]
,temp->item.num[2]
,temp->item.mony
,temp->item.gra);
}
}
char* VIP::sex(const VIP::Node *v)
{
return v->item.morw==1?"Man":"Woman";
}
bool VIP::Err(char *n)
{
Node *temp=head;
while(temp!=NULL)
{
if(!strcmp(temp->item.num[0],n))
{
cout<< "该会员卡号已存在,请重新输入"<
return true;
}
else temp=temp->next;
}
return false;
}
VIP::Node * VIP::InTheVIP()
{
char n[11];
cout<
cin.getline(n,10);
Node *temp=head;
while(temp!=NULL)
{
if(strcmp(temp->item.num[0],n)==0)
{
show(temp);
return temp;
}
else if(temp->next==NULL)
{
cout<< "没有这个会员,重新输入或在查询会员资料处进行模糊查找(q 退出):"<< endl;
cin.getline(n,10);
if(!strcmp(n,"q"))
break;
temp=head;
continue;
}
temp=temp->next;
}
return NULL;
}
bool VIP::ToTheFile(FILE *pf)
{
int i;
Node* temp=head;
fseek(pf,0L,SEEK_SET);
for( i=0;i
{
fseek(pf,i*sizeof(Item),SEEK_SET);
fwrite(&temp->item,sizeof(Item),1,pf);
temp=temp->next;
}
return true;
}