银行叫号系统

银行叫号系统简单实现,不过请放心使用时间紧凑,仅仅添加部分功能,后续可以使用Qt实现界面大家也可以根据本代码进行更改,添加更多功能与细节流程用户进入系统导航页面循环:选择进入系统或退出系统输入姓名选择身份选择业务添加顾客,调用addCustomer打印叫号等待界面调用waitingInterface打印有顾客的窗口队列个人counter0:InDAWcounter1:InFNPcounter2: InACTcounter3:InLON公司
摘要由CSDN通过智能技术生成

银行叫号系统

简单实现,不过请放心使用

时间紧凑,仅仅添加部分功能,后续可以使用Qt实现界面

大家也可以根据本代码进行更改,添加更多功能与细节

流程

  1. 用户进入系统导航页面
    1. 循环:
      1. 选择进入系统或退出系统
      2. 输入姓名
      3. 选择身份
      4. 选择业务
      5. 添加顾客,调用addCustomer
  2. 打印叫号等待界面
    1. 调用waitingInterface打印有顾客的窗口

队列

  1. 个人
    1. counter0:InDAW
    2. counter1:InFNP
    3. counter2: InACT
    4. counter3:InLON
  2. 公司
    1. counter4:EnMAN
    2. counter5:EnLOA

顾客:类Customer

  1. 成员变量:
    1. string name 用户姓名
    2. string identity 用户身份 individual/enterprise
    3. string business 业务
      1. individual DAW取钱 FNP理财产品 ACC开户 LOA贷款
      2. enterprise MAN资金管理 LOA贷款
    4. string serialNumber 序列号 例如 IDA_0
    5. int numInQueue 在对应队列中的序号
    6. double balance 余额
  2. 构造函数:一个是默认,一个是传入三个参数
    1. 默认构造函数:
    this->name = "<nemo>";
    this->identity = "<nemo>";
    this->business = "<nemo>";
    this->serialNumber = "";
    this->numInQueue = -1;
    this->balance = 0.00;
2. 含参构造函数:
    Customer::Customer(string aName, string anIdentity, string aBusiness) {
        this->name = std::move(aName); 
        this->identity = std::move(anIdentity);
        this->business = std::move(aBusiness);
        this->balance = 50000.00;
        this->serialNumber = "";
        this->numInQueue = -1; 
    }

银行:类BankServer

  1. 成员变量:
    1. counter0 ~ counter5 5个队列
    2. 为了方便就没有写构造函数,直接初始化
    queue<Customer> counter0 = queue<Customer>();
    queue<Customer> counter1 = queue<Customer>();
    queue<Customer> counter2 = queue<Customer>();
    queue<Customer> counter3 = queue<Customer>();
    queue<Customer> counter4 = queue<Customer>();
    queue<Customer> counter5 = queue<Customer>();
  1. 添加顾客:addCustomer:
    1. 传入参数:顾客 Customer &c
    2. 根据身份分配柜台
      1. 初始化对应序列号
      2. 初始化在队列中的编号
      3. 入队
      4. 打印等待单据
void Bank::addCustomer(Customer &c) {

    // according to the identity, allocate different counters and this serialNumber
    if (c.identity == "individual") {
        if (c.business == "DAW") {
            c.serialNumber = c.serialNumber + "IDA_" + to_string(counter0.size());
            c.numInQueue = counter0.size();
            counter0.enQueue(c);

            printData(c);

            cout << "Enqueuing ... \n" << endl;

        } else if (c.business == "FNP") {
            c.serialNumber = c.serialNumber + "IFP_" + to_string(counter1.size());
            c.numInQueue = counter1.size();
            counter1.enQueue(c);

            printData(c);

            cout << "Enqueuing ... \n" << endl;

        } else if (c.business == "ACC") {
            c.serialNumber = c.serialNumber + "IAC_" + to_string(counter2.size());
            c.numInQueue = counter2.size();
            counter2.enQueue(c);

            printData(c);

            cout << "Enqueuing ... \n" << endl;

        } else if (c.business == "LOA") {
            c.serialNumber = c.serialNumber + "ILO_" + to_string(counter3.size());
            c.numInQueue = counter3.size();
            counter3.enQueue(c);

            printData(c);

            cout << "Enqueuing ... \n" << endl;

        }
    } else if (c.identity == "enterprise") {
        if (c.business == "MAN") {
            c.serialNumber = c.serialNumber + "EMA_" + to_string(counter4.size());
            c.numInQueue = counter4.size();
            counter4.enQueue(c);

            printData(c);

            cout << "Enqueuing ... \n" << endl;

        } else if (c.business == "LOA") {
            c.serialNumber = c.serialNumber + "ELO_" + to_string(counter5.size());
            c.numInQueue = counter5.size();
            counter5.enQueue(c);

            printData(c);

            cout << "Enqueuing ... \n" << endl;

        }
    }
}
  1. 打印叫号凭据:printData
    cout << "NAME: " << c.name << endl;
    cout << "IDEN: " << c.identity << endl;
    cout << "BUSI: " << c.business << endl;
    cout << "NUMB: " << c.serialNumber << endl;

    if (c.numInQueue == 0) {
        cout << "Handling the business..." << endl;
    } else {
        cout << "There are " << c.numInQueue << " people in front of you." << endl;
    };

    cout << endl;
}
  1. 打印等待界面
void Bank::waitingInterface() {
    string arrow = "->";

    int count = 1;

    while (!counter0.isEmpty() || !counter1.isEmpty() || !counter2.isEmpty() ||
           !counter3.isEmpty() || !counter4.isEmpty() || !counter5.isEmpty()) {

        cout << "\n" << "###### Interface: " << count << " ######" << endl;

        // print 0
        if (!counter0.isEmpty()) {
            cout << "\n****** Individual Draw and Withdraw ******" << endl;

            for (int i = 0; i < counter0.size(); i++) {
                if (i == 0) {
                    cout << arrow << " " << counter0.get(0).numInQueue << " " << counter0.get(0).serialNumber <<
                         " " << counter0.get(0).name << endl;
                } else {
                    cout << "  " << " " << counter0.get(i).numInQueue << " " << counter0.get(i).serialNumber <<
                         " " << counter0.get(i).name << endl;
                }
            }

            counter0.deQueue();
        }

        // print 1
        if (!counter1.isEmpty()) {
            cout << "\n****** Individual Financial Products ******" << endl;

            for (int i = 0; i < counter1.size(); i++) {
                if (i == 0) {
                    cout << arrow << " " << counter1.get(0).numInQueue << " " << counter1.get(0).serialNumber <<
                         " " << counter1.get(0).name << endl;
                } else {
                    cout << "  " << " " << counter1.get(i).numInQueue << " " << counter1.get(i).serialNumber <<
                         " " << counter1.get(i).name << endl;
                }
            }

            counter1.deQueue();
        }

        // print 2
        if (!counter2.isEmpty()) {
            cout << "\n****** Individual Account ******" << endl;

            for (int i = 0; i < counter2.size(); i++) {
          
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值