JAVA的不懂,求大神指点

Ten0704 2015-10-02 10:07:25
/**
* TicketCounter demonstrates the use of a queue for simulating a waiting line.
*
* @author Dr. Lewis
* @author Dr. Chase
* @version 1.0, 08/12/08
*/

import jss2.*;

public class TicketCounter
{
final static int PROCESS = 120;
final static int MAX_CASHIERS = 10;
final static int NUM_CUSTOMERS = 100;

public static void main ( String[] args)
{
Customer customer;
LinkedQueue<Customer> customerQueue = new LinkedQueue<Customer>();
int[] cashierTime = new int[MAX_CASHIERS];
int totalTime, averageTime, departs;

/** process the simulation for various number of cashiers */
for (int cashiers=0; cashiers < MAX_CASHIERS; cashiers++)
{
/** set each cashiers time to zero initially*/
for (int count=0; count < cashiers; count++)
cashierTime[count] = 0;

/** load customer queue */
for (int count=1; count <= NUM_CUSTOMERS; count++)
customerQueue.enqueue(new Customer(count*15));

totalTime = 0;

/** process all customers in the queue */
while (!(customerQueue.isEmpty()))
{
for (int count=0; count <= cashiers; count++)
{
if (!(customerQueue.isEmpty()))
{
customer = customerQueue.dequeue();
if (customer.getArrivalTime() > cashierTime[count])
departs = customer.getArrivalTime() + PROCESS;
else
departs = cashierTime[count] + PROCESS;
customer.setDepartureTime (departs);
cashierTime[count] = departs;
totalTime += customer.totalTime();
}
}
}

/** output results for this simulation */
averageTime = totalTime / NUM_CUSTOMERS;
System.out.println ("Number of cashiers: " + (cashiers+1));
System.out.println ("Average time: " + averageTime + "\n");
}
}
}
下面几处不懂,求大神解释一下。
LinkedQueue<Customer> customerQueue = new LinkedQueue<Customer>();
customerQueue.enqueue(new Customer(count*15));
customer = customerQueue.dequeue();
...全文
107 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
异常异长 2015-10-03
  • 打赏
  • 举报
回复
这个就要看 LinkedQueue 这个类的方法都做什么了 所以你要找到LinkedQueue这个类 一切就知道了

23,405

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧