本文整理汇总了C++中Customer::set_number方法的典型用法代码示例。如果您正苦于以下问题:C++ Customer::set_number方法的具体用法?C++ Customer::set_number怎么用?C++ Customer::set_number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::set_number方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (void)
{
//setting up the 5 lines of cashiers
Cashier cashier1;
Cashier cashier2;
Cashier cashier3;
Cashier cashier4;
Cashier cashier5;
//creating Customer variable to temporarily hold input
Customer cust;
//creating queue to hold input from file
queue<Customer> custInput;
//creating variable to hold simulation data
Sim_data_type sim;
//file for getting input
ifstream in_file;
//used to temperarily hold the line obtained from the file
string line;
//used to temperarily hold the selected substring
string substring;
//opening file
in_file.open("output.dat");
if( in_file.fail() )
{
cout<<"Could not open file.\n";
return 0;
}
else
{
//get data from file until end of file
while( !in_file.eof() )
{
//gets input until new line
getline( in_file, line );
//if extracted string isn't empty
if( line.length() > 0 )
{
//getting the first digits for (number)
substring = line.substr(0, 2);
cust.set_number( atoi(substring.c_str()) );
//getting the next digits for (arrival_time)
substring = line.substr(4, 4);
cust.set_arrival_time( atoi(substring.c_str()) );
//getting the next digits for (serv_time)
substring = line.substr(9, 3);
cust.set_serv_time( atoi(substring.c_str()) );
//adding newly created customer to the data queue
custInput.push( cust );
}
}
//closing file
in_file.close();
}
//while store not closed
while( sim.get_cnt() < 600 )
{
//increment minutes
sim.inc_cnt();
cashier1.inc_timer();
cashier2.inc_timer();
cashier3.inc_timer();
cashier4.inc_timer();
cashier5.inc_timer();
//while customers can still be served
if( sim.get_cnt() < 570 )
{
//set cust to temporarily hold front of custInput
cust = custInput.front();
//if the front of queue is ready to join line
while( cust.get_arrival_time() == sim.get_cnt() )
{
//set the customer to the first available/shortest
//lane; if none are open turn them away
//.........这里部分代码省略.........