Я просто ищу подсказку, которая поможет мне запустить эту программу, чтобы у меня было несколько «строк». В настоящее время у меня есть 1 строка, и я пытаюсь добавить еще две строки (LinkedQueues). Я должен сделать программу, чтобы иметь 3 строки. вместо одной строки. Я просто ищу некоторую возможную помощь при попытке запустить эту программу с
public class WaitLine
{
private QueueInterface<Customer> line, line2, line3;
private int numberOfArrivals;
// private int numberOfArrivals1;
//private int numberOfArrivals2;
//private int numberOfArrivals3;
private int numberServed;
private int totalTimeWaited;
public WaitLine()
{
line = new LinkedQueue<>();
line2 = new LinkedQueue<>();
line3 = new LinkedQueue<>();
reset();
} // end default constructor
/** Task: Simulates a waiting line with one serving agent.
* @param duration the number of simulated minutes
* @param arrivalProbability a real number between 0 and 1, and the
* probability that a customer arrives at
* a given time
* @param maxTransactionTime the longest transaction time for a
* customer */
public void simulate(int duration, double arrivalProbability,
int maxTransactionTime)
{
int transactionTimeLeft = 0;
for (int clock = 0; clock < duration; clock++) {
if (Math.random() < arrivalProbability) {
numberOfArrivals++;
int transactionTime = (int)(Math.random() * maxTransactionTime + 1);
Customer nextArrival = new Customer(clock, transactionTime, numberOfArrivals);
line.enqueue(nextArrival);
System.out.println("Customer " + numberOfArrivals
+ " enters line at time " + clock
+ ". Transaction time is " + transactionTime);
} // end if
if (transactionTimeLeft > 0)
transactionTimeLeft--;
else if (!line.isEmpty())
{
Customer nextCustomer = line.dequeue();
transactionTimeLeft = nextCustomer.getTransactionTime() - 1;
int timeWaited = clock - nextCustomer.getArrivalTime();
totalTimeWaited = totalTimeWaited + timeWaited;
numberServed++;
System.out.println("Customer " + nextCustomer.getCustomerNumber()
+ " begins service at time " + clock
+ ". Time waited is " + timeWaited);
} // end if
} // end for
} // end simulate
/** Task: Displays summary results of the simulation. */
public void displayResults()
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
System.out.println();
System.out.println("LINE 1:");
System.out.println("Number served = " + numberServed);
System.out.println("Total time waited = " + totalTimeWaited);
double averageTimeWaited = ((double)totalTimeWaited) / numberServed;
System.out.println("Average time waited = " + averageTimeWaited);
int leftInLine = numberOfArrivals - numberServed;
System.out.println("Number left in line = " + leftInLine);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
System.out.println();
System.out.println("LINE 2:");
System.out.println("Number served = " + numberServed);
System.out.println("Total time waited = " + totalTimeWaited);
System.out.println("Average time waited = " + averageTimeWaited);
System.out.println("Number left in line = " + leftInLine);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
System.out.println();
System.out.println("LINE 3:");
System.out.println("Number served = " + numberServed);
System.out.println("Total time waited = " + totalTimeWaited);
System.out.println("Average time waited = " + averageTimeWaited);
System.out.println("Number left in line = " + leftInLine);
} // end displayResults
/** Task: Initializes the simulation. */
public final void reset()
{
line.clear();
numberOfArrivals = 0;
numberServed = 0;
totalTimeWaited = 0;
} // end reset
} // end WaitLine