本文整理汇总了C++中Customer::setServiceTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Customer::setServiceTime方法的具体用法?C++ Customer::setServiceTime怎么用?C++ Customer::setServiceTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::setServiceTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rand
std::vector<float> SimRunner::multiQueueSim(int minutes, int serviceTimeLow, int serviceTimeHigh, bool useCarts, int queues)
{
std::vector<std::vector<Customer*> > waitingCustomerQueues;
std::vector<Customer*> servedCustomers;
for(int i = 0; i < queues; i++)
{
std::vector<Customer*> temp;
waitingCustomerQueues.push_back(temp);
}
for(int i = 0; i < minutes; i++)
{
for(int j = 0; j < waitingCustomerQueues.size(); j++)
{
for(int k = 0; k < waitingCustomerQueues.at(j).size(); k++)
{
waitingCustomerQueues.at(j).at(k)->setWaitTime(waitingCustomerQueues.at(j).at(k)->getWaitTime() + 1);
}
}
Customer *currentCustomer = NULL;
for(int j = 0; j < queues; j++)
{
if(waitingCustomerQueues.at(j).size() > 0)
{
currentCustomer = waitingCustomerQueues.at(j).at(0);
currentCustomer->setServiceTime(currentCustomer->getServiceTime()-1);
if(currentCustomer->getServiceTime() <= 0)
{
waitingCustomerQueues.at(j).erase(waitingCustomerQueues.at(j).begin(),waitingCustomerQueues.at(j).begin()+1);
servedCustomers.push_back(currentCustomer);
}
}
}
int newCustomers = rand() % 3;
for(int j = 0; j < newCustomers; j++)
{
int serviceTime = 0;
if(!useCarts)
{
if(serviceTimeLow == serviceTimeHigh || serviceTimeLow > serviceTimeHigh)
{
serviceTime = serviceTimeLow;
}
else
{
serviceTime = rand() % (serviceTimeHigh - serviceTimeLow) + serviceTimeLow;
}
}
else
{
if(serviceTimeLow == serviceTimeHigh || serviceTimeLow > serviceTimeHigh)
{
serviceTime = serviceTimeLow / 6;
if(serviceTimeLow % 6 != 0)
{
serviceTime++;
}
}
else
{
int numItems = rand() % (serviceTimeHigh - serviceTimeLow) + serviceTimeLow;
serviceTime = numItems / 6;
if(numItems % 6 != 0)
{
serviceTime++;
}
}
}
currentCustomer = new Customer();
currentCustomer->setServiceTime(serviceTime);
int smallestIndex = 0;
int smallestSize = waitingCustomerQueues.at(0).size();
for(int j = 0; j < waitingCustomerQueues.size(); j++)
{
if(waitingCustomerQueues.at(j).size() < smallestSize)
{
smallestIndex = j;
smallestSize = waitingCustomerQueues.at(j).size();
}
}
waitingCustomerQueues.at(smallestIndex).push_back(currentCustomer);
}
}
std::vector<float> returnVector;
returnVector.push_back(servedCustomers.size());
int totalWaitTime = 0;
//.........这里部分代码省略.........