本文主要是介绍OUC_之校园智能卡管理系统(final)(源码),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//密码类
#ifndef KEYWORD_H
#define KEYWORD_H#include <string>using namespace std;class Keyword
{string keyword_string; //密文 int maxn, minn; //密文最大位数和最小位数 int num; //密文错误次数 public:Keyword() : keyword_string(""), maxn(16), minn(8), num(0){} //构造函数 string get_keyword(){return keyword_string;} //获取与设置密文 void set_keyword(string str){this->keyword_string = str;}int get_maxn(){return maxn;} //获取密文最大最小位数 int get_minn(){return minn;}void add_num(){num++;} //增加与清空错误次数 void clear_num(){num = 0;}int get_nums(){return num;} //获取错误次数
};#endif
//金钱类
#ifndef MONEY_H
#define MONEY_Husing namespace std;class Money
{double base_money; //基础金额 int type; //金钱类型(默认人民币) public:Money(double money) : base_money(money), type(0){}; //构造函数 double get_money(){return base_money;} //获取金钱 void add_money(double money){base_money += money;} //增加、减少、设置金钱 void sub_money(double money){base_money -= money;}void set_money(double money){base_money = money;}
};#endif
//用户类
#ifndef PERSON_H
#define PERSON_H
#include <string>
#include <iostream>using namespace std;class Person
{string person_name; //用户姓名 string person_sex; //用户性别 string person_unit; //用户单位 string person_status; //用户身份 public:string get_name(){return person_name;} //获取与更改用户姓名 void set_name(string name){person_name = name;}string get_sex(){return person_sex;} //获取与更改用户性别 void set_sex(string sex){person_sex = sex;}string get_unit(){return person_unit;} //获取与更改用户单位 void set_unit(string unit){person_unit = unit;}string get_status(){return person_status;} //获取与更改用户身份 void set_status(string status){person_status = status;}
};#endif
//学生类
#ifndef STUDENT_H
#define STUDENT_H#include <string>
#include <iostream>
#include "person.h"using namespace std;class Student : public Person
{string student_name; //学生姓名string student_sex; //学生性别string student_unit; //学生单位string student_status; //学生身份public:string get_name(){return student_name;} //获取与更改学生姓名void set_name(string name){student_name = name;}string get_sex(){return student_sex;} //获取与更改学生性别void set_sex(string sex){student_sex = sex;}string get_unit(){return student_unit;} //获取与更改学生单位void set_unit(string unit){student_unit = unit;}string get_status(){return student_status;} //获取与更改学生身份void set_status(string status){student_status = status;}
};#endif // STUDENT_H
//教师类
#ifndef TEACHER_H
#define TEACHER_H#include <iostream>
#include <string>
#include "person.h"class Teacher : public Person
{string teacher_name; //教师姓名string teacher_sex; //教师性别string teacher_unit; //教师单位string teacher_status; //教师身份public:string get_name(){return teacher_name;} //获取与更改教师姓名void set_name(string name){teacher_name = name;}string get_sex(){return teacher_sex;} //获取与更改教师性别void set_sex(string sex){teacher_sex = sex;}string get_unit(){return teacher_unit;} //获取与更改教师单位void set_unit(string unit){teacher_unit = unit;}string get_status(){return teacher_status;} //获取与更改教师身份void set_status(string status){teacher_status = status;}
};#endif // TEACHER_H
//智能卡类
#ifndef ECARD_H
#define ECARD_H
#include <iostream>
#include "Keyword.h"
#include "money.h"
#include "person.h"using namespace std;class Ecard
{long long Ecard_num; //卡号 Money Ecard_balance; //余额 Person person; //用户 Keyword keyword; //密码 bool Ecard_state; //状态 public:Ecard() : Ecard_num(0), Ecard_balance(0), Ecard_state(true){}; //构造函数 long long get_num(){return Ecard_num;} //获取卡号 void set_num(long long num){this->Ecard_num = num;} //设置卡号 double get_balance(){return Ecard_balance.get_money();} //获取金钱 void deposit_balance(double money){Ecard_balance.add_money(money);} //存钱 void withdraw_balance(double money){Ecard_balance.sub_money(money);} //消费 bool get_state(){return Ecard_state;} //得到状态 void set_state(bool flag){Ecard_state = flag;} //设置状态 void set_keyword(string str){keyword.set_keyword(str);} //设置密码 string get_keyword(){return keyword.get_keyword();} //获取密码 void add_num(){keyword.add_num();} //增加密码错误次数 void clear_num(){keyword.clear_num();} //清空密码错误次数 int get_nums(){return keyword.get_nums();} //获取密码错误次数 string get_name(){return person.get_name();} //获取与更改用户姓名void set_name(string name){person.set_name(name);}string get_sex(){return person.get_sex();} //获取与更改用户性别void set_sex(string sex){person.set_sex(sex);}string get_unit(){return person.get_unit();} //获取与更改用户单位void set_unit(string unit){person.set_unit(unit);}string get_status(){return person.get_status();} //获取与更改用户身份void set_status(string status){person.set_status(status);}
};#endif
#ifndef SECARD_H
#define SECARD_H
#include <iostream>
#include "Keyword.h"
#include "money.h"
#include "student.h"using namespace std;class Secard
{long long Ecard_num; //卡号Money Ecard_balance; //余额Student student; //用户Keyword keyword; //密码bool Ecard_state; //状态public:Ecard() : Ecard_num(0), Ecard_balance(0), Ecard_state(true){}; //构造函数long long get_num(){return Ecard_num;} //获取卡号void set_num(long long num){this->Ecard_num = num;} //设置卡号double get_balance(){return Ecard_balance.get_money();} //获取金钱void deposit_balance(double money){Ecard_balance.add_money(money);} //存钱void withdraw_balance(double money){Ecard_balance.sub_money(money);} //消费bool get_state(){return Ecard_state;} //得到状态void set_state(bool flag){Ecard_state = flag;} //设置状态void set_keyword(string str){keyword.set_keyword(str);} //设置密码string get_keyword(){return keyword.get_keyword();} //获取密码void add_num(){keyword.add_num();} //增加密码错误次数void clear_num(){keyword.clear_num();} //清空密码错误次数int get_nums(){return keyword.get_nums();} //获取密码错误次数string get_name(){return student.get_name();} //获取与更改用户姓名void set_name(string name){student.set_name(name);}string get_sex(){return student.get_sex();} //获取与更改用户性别void set_sex(string sex){student.set_sex(sex);}string get_unit(){return student.get_unit();} //获取与更改用户单位void set_unit(string unit){student.set_unit(unit);}string get_status(){return student.get_status();} //获取与更改用户身份void set_status(string status){student.set_status(status);}
};
#endif // SECARD_H
#ifndef TECARD_H
#define TECARD_H
#include <iostream>
#include "Keyword.h"
#include "money.h"
#include "teacher.h"using namespace std;class Tecard
{long long Ecard_num; //卡号Money Ecard_balance; //余额Teacher teacher; //用户Keyword keyword; //密码bool Ecard_state; //状态public:Ecard() : Ecard_num(0), Ecard_balance(0), Ecard_state(true){}; //构造函数long long get_num(){return Ecard_num;} //获取卡号void set_num(long long num){this->Ecard_num = num;} //设置卡号double get_balance(){return Ecard_balance.get_money();} //获取金钱void deposit_balance(double money){Ecard_balance.add_money(money);} //存钱void withdraw_balance(double money){Ecard_balance.sub_money(money);} //消费bool get_state(){return Ecard_state;} //得到状态void set_state(bool flag){Ecard_state = flag;} //设置状态void set_keyword(string str){keyword.set_keyword(str);} //设置密码string get_keyword(){return keyword.get_keyword();} //获取密码void add_num(){keyword.add_num();} //增加密码错误次数void clear_num(){keyword.clear_num();} //清空密码错误次数int get_nums(){return keyword.get_nums();} //获取密码错误次数string get_name(){return teacher.get_name();} //获取与更改用户姓名void set_name(string name){teacher.set_name(name);}string get_sex(){return teacher.get_sex();} //获取与更改用户性别void set_sex(string sex){teacher.set_sex(sex);}string get_unit(){return teacher.get_unit();} //获取与更改用户单位void set_unit(string unit){teacher.set_unit(unit);}string get_status(){return teacher.get_status();} //获取与更改用户身份void set_status(string status){teacher.set_status(status);}
};
#endif // TECARD_H
#ifndef TREAP_NODE_H
#define TREAP_NODE_Hclass Treap_Node
{public:Treap_Node *left, *right;int fix, size, weight, num;long long value;int lsize(){return left ? left->size : 0;}int rsize(){return right ? right->size : 0;}
};#endif // TREAP_NODE_H
#ifndef TREAP_H
#define TREAP_H#include <iostream>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdlib>
#include "ecard.h"
#include "treap_node.h"using namespace std;class Treap //Treap树
{public:Treap_Node *root;Treap() : root(NULL) {srand(time(0));} //构造函数void ins(Treap_Node *&p, long long value, int i); //插入void del(Treap_Node *&p, long long value); //删除int find(Treap_Node *&p, long long value);void left_rotate(Treap_Node *&p); //左旋void right_rotate(Treap_Node *&p); //右旋
};inline void Treap::ins(Treap_Node *&p, long long value, int i)
{if (!p){p = new Treap_Node;p->value = value;p->num = i;p->fix = rand();p->left = NULL;p->right = NULL;}else if (value <= p->value){Treap::ins(p->left, value, i);if (p->left->fix < p->fix){right_rotate(p);}}else{Treap::ins(p->right, value, i);if (p->right->fix < p->fix){left_rotate(p);}}
}inline int Treap::find(Treap_Node *&p, long long value)
{if (p){if (p->value == value){return p->num;}else if (value < p->value){find(p->left, value);}else{find(p->right, value);}}else{return -1;}
}inline void Treap::left_rotate(Treap_Node *&p)
{Treap_Node *s = p->right;p->right = s->left;s->left = p;p = s;
}inline void Treap::right_rotate(Treap_Node *&p)
{Treap_Node *s = p->left;p->left = s->right;s->right = p;p = s;
}#endif // TREAP_H
这篇关于OUC_之校园智能卡管理系统(final)(源码)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!