card.h
#pragma once
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool checkLetterAndNumberString(string str);
string getTime();
class Card {
public:
int id;
string password;
string date;
string user_name;
int deposit;
Card(int _id,string _password, string _date, string _name, int _de) {
id = _id;
password = _password;
date = _date;
user_name = _name;
deposit = _de;
}
//校验密码
bool check_password();
//重置密码
bool reset_password();
virtual bool fun_pay(int amount);
//文件流读写,获取流水信息
void fun_acquir_flow();
//文件流读写,获取持卡人信息
virtual void fun_acquir_person();
};
class Campus_Card :public Card {
public:
string college;
Campus_Card(int _id, string _password, string _date, string _name, int _de,string _college) :Card(_id, _password, _date, _name, _de) {
college = _college;
}
bool fun_pay(int amount);
void fun_acquir_person();
};
class Deposit_Card :public Card {
public:
//overdraw_max=500$
int overdraw;
Deposit_Card(int _id,string _password, string _date, string _name, int _de, int _over=0) :Card(_id, _password, _date, _name, _de) {
overdraw = _over;
}
//判断能否支付
bool check_enough(int amount) {
if (overdraw - deposit + amount > 500) {
return 0;
}
return 1;
}
//通过现金充值
bool deposit1(int amount);
//通过别的储蓄卡充值
bool deposit2(int amount,Deposit_Card* tp);
//转账给储蓄卡
bool transfer1(int amount,Deposit_Card* tp);
//转账给学生卡
bool transfer2(int amount,Campus_Card* tp);
bool fun_pay(int amount);
void fun_acquir_person();
};
//根据id匹配函数
class Binding_Card :public Campus_Card {
public:
//至多三张储蓄卡
Deposit_Card* D[3];
Binding_Card(int _id,string _password, string _date, string _name, int _de, string _college, Deposit_Card* _id1=0, Deposit_Card* _id2=0, Deposit_Card* _id3=0) :Campus_Card(_id, _password, _date, _name, _de, _college) {
D[0] = _id1;
D[1] = _id2;
D[2] = _id3;
}
void fun_acquir_person();
bool fun_pay(int amount);
};
card.cpp
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <fstream>
using namespace std;
//Card 的实现
#include "Card.h"
bool checkLetterAndNumberString(string str) {
if (str.size() > 20 || str.size() < 8)
return false;
for (int i = 0; i < str.size(); i++) {
if ((str[i] >= '0' && str[i] <= '9') || (str[i] >= 'a' && str[i] <= 'z') ||
(str[i] >= 'A' && str[i] <= 'Z')) {
continue;
}
else {
return false;
}
}
return true;
}
bool Card::check_password() {
cout << "Please inpute your password" << endl;
string temp;
cin >> temp;
if (temp != password) {
cout << "Wrong password!" << endl;
return 0;
}
else
return 1;
}
bool Card::reset_password() {
cout << "Please input your old password" << endl;
string temp;
cin >> temp;
if (temp == password) {
cout << "Now to reset the password" << endl;
cout << "Please input the new password(just Letter or Number and the lenth must between 8 to 20)" << endl;
cin >> temp;
while(!checkLetterAndNumberString(temp)) {
cout << "Failed.Bad password." << endl;
cout << "Please input the new password(just Letter or Number and the lenth must between 8 to 20)" << endl;
}
password = temp;
return 1;
}
else {
cout << "Wrong password\nReset failed" << endl;
return 0;
}
}
#include <time.h>
//获得当前系统时间
string getTime()
{
time_t timep;
time(&timep); //获取time_t类型的当前时间
char tmp[64];
strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&timep));//对日期和时间进行格式化
return tmp;
}
bool Card::fun_pay(int amount) {
if (deposit < amount) {
cout << "Deposit not enough" << endl;
return 0;
}
deposit -= amount;
cout << "Payment successful" << endl;
fstream file;
file.open("flow.txt", ios::app, 0);
file << getTime() << endl;
file << "Card(ID:" << id << ") : -" << amount << " Deposit: " << deposit << endl;
file.close();
}
void Card::fun_acquir_flow() {
fstream file;
file.open("flow.txt", ios::in);
string temp;
if (file.is_open()) {
while (file.peek() != EOF) {
file >> temp;
cout << temp;
}
file.close();
}
else {
cout << "Failed to open flow.txt" << endl;
}
return;
}
void Card::fun_acquir_person() {
cout << "This is a Card" << endl;
cout << "ID: " << id << endl << "DATE: " << date << endl;
cout << "User_name: " << user_name << endl;
cout << "Deposit: " << deposit << endl;
cout << endl;
return;
}
bool Campus_Card::fun_pay(int amount) {
if (deposit < amount) {
cout << "Deposit not enough" << endl;
return 0;
}
deposit -= amount;
cout << "Payment successful" << endl;
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Campus_Card(ID:" << id << ") : -" << amount << " Deposit: " << deposit << endl;
file.close();
}
void Campus_Card::fun_acquir_person() {
cout << "This is a Campus_Card" << endl;
cout << "ID: " << id << endl << "DATE: " << date << endl;
cout << "User_name: " << user_name << endl;
cout << "College: " << college << endl;
cout << "Deposit: " << deposit << endl;
cout << endl;
return;
}
bool Deposit_Card::fun_pay(int amount) {
if (overdraw - deposit + amount > 500) {
cout << "Failed! Out of The Maxmum of Overdraw" << endl;
return 0;
}
else {
if (deposit > 0) {
if (deposit > amount) {
deposit -= amount;
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Deposit_Card(ID:" << id << ") : -" << amount << " Deposit: " << deposit << " Overdraw: " << overdraw << endl;
file.close();
}
else {
overdraw = amount-deposit;
deposit = 0;
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Deposit_Card(ID:" << id << ") : -" << amount << " Deposit: " << deposit << " Overdraw: " << overdraw << endl;
file.close();
}
}
else {
overdraw += amount;
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Deposit_Card(ID:" << id << ") : -" << amount << " Deposit: " << deposit << " Overdraw: " << overdraw << endl;
file.close();
}
}
return 1;
}
bool Deposit_Card::deposit1(int amount) {
cout << "Successfully deposit " << amount << " $ to Deposit_Card(ID:" <<id<<")"<< endl;
if (overdraw > 0) {
if (overdraw > amount) {
overdraw -= amount;
}
else {
overdraw = 0;
deposit = amount - overdraw;
}
}
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Deposit_Card(ID:" << id << ") : +" << amount << " Deposit: " << deposit << " Overdraw: " << overdraw << endl;
file.close();
return 1;
}
bool Deposit_Card::deposit2(int amount, Deposit_Card* tp) {
if (!tp->check_enough(amount)) {
cout<< "Failed! Out of The Maxmum of Overdraw" << endl;
return 0;
}
else {
tp->fun_pay(amount);
deposit1(amount);
cout << "Successfully deposit " << amount << " $ to Deposit_Card(ID:" << id << ")" << endl;
}
return 1;
}
bool Deposit_Card::transfer1(int amount, Deposit_Card* tp) {
if (!check_enough(amount)) {
cout << "Failed! Out of The Maxmum of Overdraw" << endl;
return 0;
}
else {
return tp->deposit2(amount, this);
}
}
bool Deposit_Card::transfer2(int amount, Campus_Card* tp) {
if (!check_enough(amount)) {
cout << "Failed! Out of The Maxmum of Overdraw" << endl;
return 0;
}
else {
fun_pay(amount);
tp->deposit += amount;
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Campus_Card(ID:" << id << ") : +" << amount << " Deposit: " << deposit << endl;
file.close();
cout << "Successfully deposit " << amount << " $ to Campus_Card(ID:" << id << ")" << endl;
return 1;
}
}
void Deposit_Card::fun_acquir_person() {
cout << "This is a Deposit_Card" << endl;
cout << "ID: " << id << endl << "DATE: " << date << endl;
cout << "User_name: " << user_name << endl;
cout << "Deposit: " << deposit << endl;
cout << "Overdraw: " << overdraw << endl;
cout << endl;
return;
}
//void Binding_Card::fun_acquir_person() {
// cout << "This is a Binding_Card" << endl;
// cout << "ID: " << id << endl << "DATE: " << date << endl;
// cout << "User_name: " << user_name << endl;
// cout << "College: " << college << endl;
// cout << "Deposit: " << deposit << endl;
// cout << endl;
// int i = 0;
// cout << "Binded Depo_Card:" << endl;
// while (D[i]) {
// cout << "The " << i << " th Deposit_Card:" << endl;
// D[i]->fun_acquir_person();
// }
// return;
//}
bool Binding_Card::fun_pay(int amount) {
if (deposit >= amount) {
deposit -= amount;
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Campus_Card(ID:" << id << ") : -" << amount << " Deposit: " << deposit << endl;
file.close();
return 1;
}
else {
amount -= deposit;
fstream file;
file.open("flow.txt", ios::app);
file << getTime() << endl;
file << "Campus_Card(ID:" << id << ") : -" << amount << " Deposit: " << deposit << endl;
file.close();
if (!D[0]->check_enough(amount)) {
if (!D[1]->check_enough(amount)) {
if (!D[2]->check_enough(amount)) {
cout << "Failed! Out of The Maxmum of Overdraw" << endl;
return 0;
}
else
D[2]->fun_pay(amount);
}
else {
D[1]->fun_pay(amount);
}
}
else
D[0]->fun_pay(amount);
}
return 1;
}
void Binding_Card::fun_acquir_person() {
cout << "This is a Binding_Card" << endl;
cout << "ID: " << id << endl << "DATE: " << date << endl;
cout << "User_name: " << user_name << endl;
cout << "College: " << college << endl;
cout << "Deposit: " << deposit << endl;
cout << endl;
cout << "The Binded Deposit_Card:" << endl;
for (int i = 0; i < 3; i++) {
if (D[i]) {
D[i]->fun_acquir_person();
}
}
return;
}
Manage.h
#pragma once
#include <string>
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
#include "Card.h"
class manage {
private:
vector<Campus_Card> Campuscard;
vector<Deposit_Card> Depositcard;
vector<Binding_Card> Bindingcard;
//按id索引
vector<Campus_Card>::iterator match_Campus(int _id);
//按姓名索引,每个学生仅能有一张校园卡
vector<Campus_Card>::iterator match_Campus_name(string _name);
vector<Deposit_Card>::iterator match_Deposit(int _id);
vector<Binding_Card>::iterator match_Binding(int _id);
public:
/*获得上次启动时的卡号信息
int Get_Stu_Id();
int Get_Dep_Id();*/
//文件操作,写入开卡信息
void Info_Campus();
void Info_Deposit();
void Info_Binding();
//文件操作,重新读取
void Read();
//具体操作
//开卡
bool Apply_a_Card();
//支付
bool to_Pay();
//转账
bool to_Transfer();
//获得流水信息
void to_acquire_flow();
//获取个人信息
void to_acquire_person();
};
Manage.cpp
#include <string>
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
#include "Manage.h"
static int student_id = 1830001;
static int deposit_id = 1;
vector<Campus_Card>::iterator manage::match_Campus(int _id) {
vector<Campus_Card>::iterator iter;
for (iter = Campuscard.begin(); iter != Campuscard.end(); iter++) {
if (iter->id == _id)
return iter;
}
return iter = Campuscard.end();
}
vector<Campus_Card>::iterator manage::match_Campus_name(string _name) {
vector<Campus_Card>::iterator iter;
for (iter = Campuscard.begin(); iter != Campuscard.end(); iter++)
if (iter->user_name == _name)
return iter;
return iter = Campuscard.end();
}
vector<Deposit_Card>::iterator manage::match_Deposit(int _id) {
vector<Deposit_Card>::iterator iter;
for (iter = Depositcard.begin(); iter != Depositcard.end(); iter++)
if (iter->id == _id)
return iter;
return iter = Depositcard.end();
}
vector<Binding_Card>::iterator manage::match_Binding(int _id) {
vector<Binding_Card>::iterator iter;
for (iter = Bindingcard.begin(); iter != Bindingcard.end(); iter++)
if (iter->id == _id)
return iter;
return iter = Bindingcard.end();
}
void manage::Info_Campus() {
fstream file;
file.open("Campus_Card.txt", ios::out);
for (vector<Campus_Card>::iterator iter = Campuscard.begin(); iter != Campuscard.end(); iter++) {
file << iter->id << endl;
file << iter->password << endl;
file << iter->date << endl;
file << iter->user_name << endl;
file << iter->deposit << endl;
file << iter->college << endl;
}
file.close();
}
void manage::Info_Deposit() {
fstream file;
file.open("Deposit_Card.txt", ios::out);
for (vector<Deposit_Card>::iterator iter = Depositcard.begin(); iter != Depositcard.end(); iter++) {
file << iter->id << endl;
file << iter->password << endl;
file << iter->date << endl;
file << iter->user_name << endl;
file << iter->deposit << endl;
file << iter->overdraw << endl;
}
file.close();
}
void manage::Info_Binding() {
fstream file;
file.open("Binding_Card.txt", ios::out);
for (vector<Binding_Card>::iterator iter = Bindingcard.begin(); iter != Bindingcard.end(); iter++) {
file << iter->id << endl;
file << iter->password << endl;
file << iter->date << endl;
file << iter->user_name << endl;
file << iter->deposit << endl;
file << iter->college << endl;
for (int i = 0; i < 3; i++) {
if (iter->D[i])
file << iter->D[i]->id << endl;
else
file << 0 << endl;
}
}
file.close();
}
void manage::Read() {
ifstream file;
file.open("Campus_Card.txt", ios::in);
if (file.is_open()) {
while (file.peek() != EOF) {
int id,deposit;
string name, password, date, college, _id, _deposit;
getline(file, _id);
getline(file, password);
getline(file, date);
getline(file, name);
getline(file, _deposit);
getline(file, college);
id = atoi(_id.c_str());
deposit = atoi(_deposit.c_str());
Campuscard.push_back(Campus_Card(id, password, date, name, deposit, college));
student_id++;
}
file.close();
}
file.open("Deposit_Card.txt", ios::in);
if (file.is_open()) {
while (file.peek() != EOF) {
int id, deposit,overdraw;
string name, password, date, _overdraw, _id, _deposit;
getline(file, _id);
getline(file, password);
getline(file, date);
getline(file, name);
getline(file, _deposit);
getline(file, _overdraw);
id = atoi(_id.c_str());
deposit = atoi(_deposit.c_str());
overdraw = atoi(_overdraw.c_str());
Depositcard.push_back(Deposit_Card(id, password, date, name, deposit,overdraw));
deposit_id++;
}
file.close();
}
file.open("Binding_Card.txt", ios::in);
if (file.is_open()) {
while (file.peek() != EOF) {
int id, deposit;
int stu_id;
string _stu_id;
Deposit_Card* _D[3] = {};
string name, password, date, college, _id, _deposit;
getline(file, _id);
getline(file, password);
getline(file, date);
getline(file, name);
getline(file, _deposit);
getline(file, college);
id = atoi(_id.c_str());
deposit = atoi(_deposit.c_str());
for (int i = 0; i < 3; i++) {
getline(file, _stu_id);
stu_id = atoi(_stu_id.c_str());
if (stu_id != 0) {
vector<Deposit_Card>::iterator iter = match_Deposit(stu_id);
_D[i] = &(*iter);
}
else {
_D[i] = NULL;
break;
}
}
Bindingcard.push_back(Binding_Card(id, password, date, name, deposit, college,_D[0],_D[1],_D[2]));
}
file.close();
}
}
bool manage::Apply_a_Card() {
cout << endl;
cout << "What kind of Card do you want to apply for?" << endl;
cout << "1.Campus_Card\n2.Deposit_Card\n3.Binding_Card\n";
cout << "Input the number:" << endl;
string ch;
cin >> ch;
cin.ignore();
if (ch == "1") {
cout << endl;
cout << "You are willing to apply for a Campus_Card" << endl;
string _name;
cout << "Please input your name" << endl;
cin >> _name;
if (match_Campus_name(_name) != Campuscard.end()) {
cout << "Failed! You have had a Campus_Card." << endl;
return 0;
}
cout << "Please input your college" << endl;
string _college;
cin >> _college;
cout << "Please input your password(just Letter or Number and the lenth must between 8 to 20)" << endl;
string _password;
cin >> _password;
while (!checkLetterAndNumberString(_password)) {
cout << "Failed.Bad password." << endl;
cout << "Please input the new password(just Letter or Number and the lenth must between 8 to 20)" << endl;
}
cout << endl;
Campuscard.push_back(Campus_Card(student_id++, _password, getTime(), _name, 0, _college));
cout << "Done!" << endl;
cout << "Your student ID :" << student_id - 1 << endl;
cout << "PLEASE KEEP IT WELL!" << endl;
}
else if (ch == "2") {
cout << endl;
cout << "You are willing to apply for a Deposit_Card" << endl;
string _name;
cout << "Please input your name" << endl;
cin >> _name;
cout << "Please input your password(just Letter or Number and the lenth must between 8 to 20)" << endl;
string _password;
cin >> _password;
cout << endl;
Depositcard.push_back(Deposit_Card(deposit_id++, _password, getTime(), _name, 0, 0));
cout << "Done!" << endl;
cout << "Your Deposit ID :" << deposit_id - 1 << endl;
cout << "PLEASE KEEP IT WELL!" << endl;
}
else if (ch == "3") {
cout << endl;
cout << "You are willing to apply for a Binding_Card" << endl;
cout << "To apply foe a Binding_Card,you should already had a Campus_Card" << endl;
cout << "Do you need apply a Campus_Card first?" << endl;
cout << "y.Yes\nn.No" << endl;
string op;
cin >> op;
cin.ignore();
if (op == "y") {
cout << endl;
cout << "You are willing to apply for a Campus_Card" << endl;
string _name;
cout << "Please input your name" << endl;
cin >> _name;
if (match_Campus_name(_name) != Campuscard.end()) {
cout << "Failed! You have had a Campus_Card." << endl;
return 0;
}
cout << "Please input your college" << endl;
string _college;
cin >> _college;
cout << "Please input your password(just Letter or Number and the lenth must between 8 to 20)" << endl;
string _password;
cin >> _password;
while (!checkLetterAndNumberString(_password)) {
cout << "Failed.Bad password." << endl;
cout << "Please input the new password(just Letter or Number and the lenth must between 8 to 20)" << endl;
}
cout << endl;
Campuscard.push_back(Campus_Card(student_id++, _password, getTime(), _name, 0, _college));
cout << "Done!" << endl;
cout << "Your student ID :" << student_id - 1 << endl;
cout << "PLEASE KEEP IT WELL!" << endl;
}
cout << "Please input your Student_id" << endl;
int _student_id;
cin >> _student_id;
vector<Binding_Card>::iterator bd = match_Binding(_student_id);
if (bd != Bindingcard.end()) {
cout << "Failed! You have already had a Binding_Card" << endl;
return 0;
}
vector<Campus_Card>::iterator tp = match_Campus(_student_id);
if (tp == Campuscard.end()) {
cout << "Failed! Not find your Campusu_Card" << endl;
return 0;
}
cout << "Please input your password(just Letter or Number and the lenth must between 8 to 20)" << endl;
string _password;
cin >> _password;
int de_id;
Deposit_Card* _D[3] = {};
for (int i = 0; i < 3; i++) {
cout << "Please input your Deposit_Card Id:('0' to inturrupt)" << endl;
cin>>de_id;
if (de_id == 0)
break;
vector<Deposit_Card>::iterator dc = match_Deposit(de_id);
if (dc == Depositcard.end()) {
cout << "Failed! The Deposit_Card isn't exist" << endl;
i--;
continue;
}
else {
if (dc->check_password()) {
_D[i] = &(*dc);
}
else {
cout << "Wrong password!" << endl;
i--;
continue;
}
}
}
Bindingcard.push_back(Binding_Card(_student_id, _password, getTime(), match_Campus(_student_id)->user_name, match_Campus(_student_id)->deposit, match_Campus(_student_id)->college, _D[0], _D[1], _D[2]));
cout << "Done!" << endl;
}
return 1;
}
//默认充值饭卡100$
bool manage::to_Pay() {
cout << endl;
cout << "What kind of card would you like to pay for this bill?" << endl;
cout << "1.Campus_Card\n2.Deposit_Card\n3.Binding_Card" << endl;
string ch;
cin >> ch;
cin.ignore();
if (ch == "1") {
cout << "Please input your Studen_Id" << endl;
int _student_id;
cin >> _student_id;
vector<Campus_Card>::iterator iter = match_Campus(_student_id);
if (iter == Campuscard.end()) {
cout << "Sorry,don't find this id!" << endl;
return 0;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return 0;
}
else {
return iter->fun_pay(100);
}
}
else if (ch == "2") {
cout << "please input your Deposit_Id" << endl;
int _deposit_id;
cin >> _deposit_id;
vector<Deposit_Card>::iterator iter = match_Deposit(_deposit_id);
if (iter == Depositcard.end()) {
cout << "Sorry,don't find this id!" << endl;
return 0;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return 0;
}
else {
return iter->fun_pay(100);
}
}
else if (ch == "3") {
cout << "Please input your Studen_Id" << endl;
int _student_id;
cin >> _student_id;
vector<Binding_Card>::iterator iter = match_Binding(_student_id);
if (iter == Bindingcard.end()) {
cout << "Sorry,don't find this id!" << endl;
return 0;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return 0;
}
else {
return iter->fun_pay(100);
}
}
return 1;
}
bool manage::to_Transfer() {
cout << endl;
cout << "Please input your Deposit_ID:" << endl;
int _deposit_id;
cin >> _deposit_id;
vector<Deposit_Card>::iterator iter = match_Deposit(_deposit_id);
if (iter == Depositcard.end()) {
cout << "Sorry,don't find this id!" << endl;
return 0;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return 0;
}
cout << "1.Transfer to another Deposit_Card\n2.Transfer to a Campus_Card" << endl;
string ch;
cin >> ch;
cin.ignore();
if (ch == "1") {
int amount = 0;
cout << "Please input the money you want to transfer" << endl;
cin >> amount;
cout << "Please input the Deposit_Card's ID:" << endl;
cin >> _deposit_id;
vector<Deposit_Card>::iterator iter2 = match_Deposit(_deposit_id);
Deposit_Card* tp = &(*iter2);
return iter->transfer1(amount, tp);
}
if (ch == "2") {
int amount = 0;
cout << "Please input the money you want to transfer" << endl;
cin >> amount;
cout << "Please input the Campus_Card's ID:" << endl;
cin >> _deposit_id;
vector<Campus_Card>::iterator iter2 = match_Campus(_deposit_id);
Campus_Card* tp = &(*iter2);
return iter->transfer2(amount, tp);
}
return 1;
}
void manage::to_acquire_flow() {
cout << endl;
cout << "Please input your Studen_Id" << endl;
int _student_id;
cin >> _student_id;
vector<Campus_Card>::iterator iter = match_Campus(_student_id);
if (iter == Campuscard.end()) {
cout << "Sorry,don't find this id!" << endl;
return;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return;
}
else {
iter->fun_acquir_flow();
}
}
void manage::to_acquire_person() {
cout << endl;
cout << "1.Campus_Card\n2.Deposit_Card\n3.Binding_Card" << endl;
string ch;
cin >> ch;
cin.ignore();
if (ch == "1") {
cout << "Please input your Studen_Id" << endl;
int _student_id;
cin >> _student_id;
vector<Campus_Card>::iterator iter = match_Campus(_student_id);
if (iter == Campuscard.end()) {
cout << "Sorry,don't find this id!" << endl;
return;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return;
}
iter->fun_acquir_person();
}
if (ch == "2") {
cout << "Please input your Deposit_ID:" << endl;
int _deposit_id;
cin >> _deposit_id;
vector<Deposit_Card>::iterator iter = match_Deposit(_deposit_id);
if (iter == Depositcard.end()) {
cout << "Sorry,don't find this id!" << endl;
return;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return;
}
iter->fun_acquir_person();
}
if (ch == "3") {
cout << "Please input your Studen_Id" << endl;
int _student_id;
cin >> _student_id;
vector<Binding_Card>::iterator iter = match_Binding(_student_id);
if (iter == Bindingcard.end()) {
cout << "Sorry,don't find this id!" << endl;
return;
}
if (!iter->check_password()) {
cout << "Failed! Wrong password!" << endl;
return;
}
iter->fun_acquir_person();
}
}
main.cpp
#include <iostream>
#include <string>
#include <vector>
#include<conio.h>
using namespace std;
#include "Card.h"
#include "Manage.h"
int main() {
cout << "Card Manager_V1.0" << endl;
cout << "Created By XYP,SYSU,18340178,2019.5" << endl;
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout << endl;
cout << "1.Apply for a Card" << endl;
cout << "2.Pay the bill" << endl;
cout << "3.Transfer" << endl;
cout << "4.Acquire flow_infomation" << endl;
cout << "5.Acquire personal infomation" << endl;
cout << "6.Exit" << endl;
//cout << "Input number to choose the operation:";
manage Maneger;
Maneger.Read();
while (1) {
cout << endl;
cout << "Input number to choose the operation:";
string ch;
cin >> ch;
cin.ignore();
if (ch == "1") Maneger.Apply_a_Card();
else if (ch == "2") Maneger.to_Pay();
else if (ch == "3") Maneger.to_Transfer();
else if (ch == "4") Maneger.to_acquire_flow();
else if (ch == "5") Maneger.to_acquire_person();
else if (ch == "6") {
Maneger.Info_Campus();
Maneger.Info_Deposit();
Maneger.Info_Binding();
cout << "Thanks for using the maneger" << endl;
return 0;
}
else cout << "Error command!\n";
cout << "\nPress any key to return.";
_getch();
//getchar();
}
}