#include <bits/stdc++.h>
using namespace std;
struct card {
//属性
string name;
int id;
string classroom;
float money;
int money_type;//0人民币 1美元 2 泰铢
string creat_time;
string tellphone;
string creat_date;
//方法
//开卡
bool creat(int i,string n,string c) {
name=n;
id=i;
classroom=c;
return true;
}
//充钱
bool Recharge(int m) {
money+=m;
}
//消费
bool consumption(int m) {
if(money>=m && m>0) {
money-=m;
return true;
}
return false;
}
};
void start() {
string name;
ifstream file;
string data;
file.open("1.txt");
//getline获取文件的一行数据
while(getline(file,data)) {
if(data.length()>5) {
name=data.substr(0,data.find("/"));
}
//eof 是否到了文件末尾
if(file.eof()) {
cout<<"end"<<endl;
break;
}
}
file.close();
}
int main() {
card cardlist[100];
int startid=1000;
int number=0;//当前有几个人办卡
while(1) {
cout<<"***太康一高附属学校充值系统***"<<endl;
cout<<"1.开卡"<<endl<<"2.充值"<<endl<<"3.消费"<<endl<<"4.余额"<<endl;
cout<<"5.挂失"<<endl<<"6.退钱"<<endl<<"7.退出系统";
cout<<endl;
int index;
cin>>index;
card c;
bool have=false;
switch(index) {
case 1:
cout<<"请输入姓名:";
cin>>c.name;
c.id=startid+number;
cardlist[number]=c;
cout<<"办卡成功!,你的卡号为"<<c.id<<endl;
number++;
break;
case 2:
cout<<"请输入你的卡号:"<<endl;
int _cid;
cin>>_cid;
for(int i=0; i<=number; i++) {
if(cardlist[i].id==_cid) {
cout<<cardlist[i].name<<"同学你好,请输入充值金额:";
int c_money;
cin>>c_money;
c.money+=c_money;
cout<<"充卡成功!目前你的卡里拥有"<<c.money<<"元"<<endl;
have=true;
break;
}
}
if(have==false) {
cout<<"对不起,该同学没有创建卡号"<<endl;
}
break;
case 3:
cout<<"请输入你的卡号:"<<endl;
int cid_,XF;
cin>>cid_;
have=false;
for(int i=0; i<=number; i++) {
if(cardlist[i].id==cid_) {
cout<<"输入你消费的金额";
cin>>XF;
c.money-=XF;
cout<<cardlist[i].name<<"你的余额为"<<c.money<<endl;
have=true;
break;
}
}
if(have==false) {
cout<<"对不起,该同学没有创建卡号"<<endl;
}
break;
case 4:
cout<<"请输入你的卡号:"<<endl;
int c_Id;
cin>>c_Id;
for(int i=0; i<=number; i++) {
if(cardlist[i].id==c_Id) {
cout<<cardlist[i].name<<"同学你好,你的余额为:"<<c.money<<"元"<<endl;
have=true;
break;
}
}
if(have==false) {
cout<<"对不起,该同学没有创建卡号"<<endl;
}
break;
}
case 5:
int b;
cout<<"请问你确定要挂失吗?"<<endl;
cout<<"如果选择挂失的话请按'1' 如果想退出的话请按'2'"<<endl;
cin>>b;
have=false;
int _cid;
if(b==1){
cout<<"请输入你要挂失的卡号:"<<endl;
cin>>_cid;
if(_cid-=c.consumption()){
cid+=c.consumption();
cout<<"叮,这个卡号已挂失";
have=true;
}
}else if(b==2){
cout<<"欢迎下次使用该系统。"<<endl;
have=true;
break;
}
if(have==false) {
cout<<"对不起,该同学没有创建卡号"<<endl;
}
break;
}
case 6:
return 0;
}
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
struct card{
//属性
string name;
int id;
string classroom;
float money;
int money_type;//0人民币 1美元 2 泰铢
string creat_time;
//方法
//开卡
bool creat(int i,string n,string c){
name=n;
classroom=c;
id=i;
return true;
}
//充钱
bool Recharge(int m){
money+=m;
return true;
}
//消费
bool consumption(int m){
if(money>=m && m>0){
money-=m;
return true;
}
return false;
}
};
int main(int argc, char** argv) {
card cardlist[100];
int startid=1000;
int number=0;//当前有几个人办卡
while(1){
cout<<"*太康一高附属学校充值系统**"<<endl;
cout<<"1.开卡"<<endl<<"2.充值"<<endl<<"3.消费"<<endl<<"4.查询余额"<<endl;
cout<<"5.挂失"<<endl<<"6.退钱"<<endl<<"7.退出系统";
cout<<endl;
int index;
cin>>index;
card c;
switch(index){
case 1:
cout<<"请输入姓名:";
cin>>c.name;
c.id=startid+number;
cardlist[number]=c;
number++;
cout<<c.id<<endl;
break;
case 2:
cout<<"请输入你的卡号:";
int _cid,_mound;
cin>>_cid;
bool have=false;
for(int i=0;i<=number;i++){
if(cardlist[i].id==_cid){
cout<<cardlist[i].name<<"同学你好,请输入充值金额:"<<endl;
cin>>_mound;
cout<<cardlist[i].name<<"同学你好,您已充值"<<_mound<<"元。"<<endl;
have=true;
break;
}
}
if(have==false){
cout<<"对不起,该同学没有创建卡号"<<endl;
}
break;
}
case 3:
int _
}
/*
卡片:
属性:
姓名:string 张三
卡号:int 123456
班级:string 三2班
余额:float 0.2
余额单位: 元
办卡时间:string 2023 11 19 08 40
手机号:string
办卡地点:string 充值点
身份证:string
家庭住址:string
每日消费上限:int 50
消费记录: string[]
最后一次消费时间:string
充值记录:string[]
挂失状态:bool
方法:
开卡 参数1:姓名、班级、
充值 参数1:int 金额
刷卡 参数1:float 金额 参数2:string 地点
挂失: 参数1 卡号
余额查询:参数1 卡号
修改姓名:参数1 卡号 参数2 新名字
删除卡片:参数1 卡号
退钱:参数1 卡号 参数2 金额
增加利息:参数1 卡号 参数2 金额
*/
return 0;
}