当前位置: 首页>>代码示例>>C++>>正文


C++ Customer::getWaitingTime方法代码示例

本文整理汇总了C++中Customer::getWaitingTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Customer::getWaitingTime方法的具体用法?C++ Customer::getWaitingTime怎么用?C++ Customer::getWaitingTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customer的用法示例。


在下文中一共展示了Customer::getWaitingTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printStatus

    void printStatus()
    {
        cout << "STATUS: ";
        util->printTime();
        Node<Cashier*> *node = this->cashierList->getFirst();
        int i = 1;
        while(node != NULL)
        {
            Cashier *c = node->getValue();
            cout << "C" << i++ << "[" << c->busyTime << "] -> ";
            Node<Customer*> *node_cust = c->customersLine->getFirst();
            while(node_cust != NULL)
            {
                Customer * cust = node_cust->getValue();
                cout << "(" << cust->getWaitingTime(util->time) << ") ";
                node_cust = node_cust->getNext();
            }

            cout << endl;

            node = node->getNext();


        }
    }
开发者ID:amandapriscilla,项目名称:portfolio,代码行数:25,代码来源:projeto.cpp

示例2: run

    void run()
    {
        int period_index = 0; // 0 a 6
        // Use util->max/minPeopleFlow
        int minFlow = util->minPeopleFlow[period_index];
        int maxFlow = util->maxPeopleFlow[period_index];
        cout << "NEW FLOW IS FROM " << minFlow << " TO " << maxFlow <<endl;

        int timeNextCustomer = util->getRand(minFlow, maxFlow);
        cout <<"First curstomer arrives in " << util->getMinute(timeNextCustomer) << "min and " << util->getSeconds(timeNextCustomer)<< " seconds" << endl;

        while(util->time <= 24 * 3600)
        {
            this->changePeriod(period_index, minFlow, maxFlow);




            int rand = util->getRand(util->minTimeAtCashier, util->maxTimeAtCachier);

            // CHECK ARRIVING CUSTOMER
            if(timeNextCustomer == 0)
            {
                // NEW CUSTOMER ARRIVE AT THE TIME CURRENT
                cout << "New Customer Arrived at "<< util->getHour(util->time) << ":" <<util->getMinute(util->time) <<"!" << endl;
                Customer *customer = new Customer(util->time);

                if (cashierList->getSize() == 0) // First cashier
                {
                    Cashier *cashier = new Cashier();
                    this->cashierList->insert(cashier);
                    cashier->customersLine->insert(customer);
                    cout << "Openning the first cashier!" << endl;
                }
                else
                {
                    // VERIFY CASHIERS AND PROCESS CUSTOMERS WAIT
                    Node<Cashier*> *node = this->cashierList->getFirst();
                    int listSize = this->cashierList->getSize();
                    for(int i=0; i<= listSize && node!=NULL; i++)
                    {
                        Cashier *cashier = node->getValue();
                        cashier->processCashier(rand);
                        if (cashier->customersLine->getSize()>0)
                        {
                            Customer *firstCustomer = cashier->getFirstCustomer();
                            int leftCustomerWaitTime = util->maxWaitLine - firstCustomer->getWaitingTime(util->time);

                            // ATTENTION!!! CUSTOMER WAITING ALERT!
                            if (cashier->busyTime > leftCustomerWaitTime) // NOT ENOUGH TIME
                            {
                                Cashier *available = getAvailableCashier(leftCustomerWaitTime);

                                if (available != NULL)
                                {
                                    available->customersLine->insert(firstCustomer);
                                }
                                else
                                {
                                    // NO OTHER CASHIER AVAILABLE
                                    Cashier *newCashier = new Cashier();
                                    newCashier->customersLine->insert(firstCustomer);
                                    cashier->customersLine->remove(firstCustomer);
                                    rand = util->getRand(util->minTimeAtCashier, util->maxTimeAtCachier);
                                    newCashier->processCashier(rand);
                                    this->cashierList->insert(newCashier);
                                    cout << "Openning an emergencial cashier! Customer waiting for more than " << util->getMinute(firstCustomer->getWaitingTime(util->time)) << " min"  << endl;
                                }
                            }
                        }

                        node = node->getNext();
                    } // End for


                    // ADD NEW CUSTOMER
                    node = this->cashierList->getFirst();
                    int minLine = 1000000, index = 0;
                    for(int i=0; i<= this->cashierList->getSize() && node!=NULL; i++)
                    {
                        Cashier *cashier = node->getValue();
                        if(cashier->getLineSize() < minLine)
                        {
                            minLine = cashier->getLineSize();
                            index = i;
                        }
                        node = node->getNext();
                    } // End for
                    LinkedList<Cashier*> *list = this->cashierList;
                    Cashier *cashier = list->getValueAt(index);
                    LinkedList<Customer*> *list1 = cashier->customersLine;
                    list1->insert(customer);
                } // END ELSE LIST NOT EMPTY

                // PREPARE NEXT CUSTOMER ARRIVING
                timeNextCustomer = util->getRand(minFlow, maxFlow);
                cout <<"Next curstomer arrives in " << util->getMinute(timeNextCustomer) << "min and " << util->getSeconds(timeNextCustomer)<< " seconds"<<endl;

            } // END CHECK ARRIVING CUSTOMER
            else
//.........这里部分代码省略.........
开发者ID:amandapriscilla,项目名称:portfolio,代码行数:101,代码来源:projeto.cpp


注:本文中的Customer::getWaitingTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。