hey guys i need some help, i posted my assignment and also the code i have so far, i'm almost done i just don't understand how round robin part works.

Write a fully documented class named Simulator that contains the main method that will simulate the system. Your method should take as command line parameters the path of the input file to read commands from followed by an integer that is between one and MAX_SERVICES, inclusive, that represents how many services that this DMV offers, located in args[0] and args[1], respectively. Once it is done setting up the queues, your program should display a menu of commands that a user at the keyboard may enter, listed below. As the simulation is in progress, you should keep track of the average wait time on the receptionist's line, the average wait time for each of the service queues, and finally the overall average waiting time for the service queues(excluding the receptionist). The waiting time for each customer should not include the processing time (i.e., the amount of time the customer spends being helped by an agent).

The simulation will basically proceed as follows: at any given time, the program may take its input commands either from the keyboard or from the input file, beginning with control coming from the keyboard. Every time that a command is read from the input file, one minute of simulation will elapse. No time elapses while commands are being read from the keyboard. To switch back and forth between the two modes of control, the input file will have a special command, Pause, which stops the program from reading from the input file and transfers control over to the user at the keyboard (a command that will cause a minute of simulation to elapse). The keyboard mode will also allow the user to type in a command called R(for Resume) that will have the program continue to read commands from the input file. This command will also be used to start the reading from the input file. The program will terminate as soon as there are no more commands in the input file that have not yet been read or if the user selects the quit option from the menu.

//Ticket class

publicclass Ticket {

/**ThetimethecustomerarrivesintheDMV*/int arrivalTime;


int receptionistTime;

/**Timeexpectedtowaitforassistance*/int expectedWaitingTime;int transactionType; String ticketNumber;publicint getArrivalTime() {

return arrivalTime;

}publicint getExpectedWaitingTime() {

return expectedWaitingTime;

}publicint getReceptionistTime() {

return receptionistTime;

}public String getTicketNumber() {

return ticketNumber

}publicint getTransactionType() {

return transactionType;





publicvoid setArrivalTime(int arrival) {

arrivalTime = arrival;

}publicvoid setExpectedWaitingTime(int i) {

expectedWaitingTime = i;

}publicvoid setReceptionistTime(int i) {

receptionistTime = i;

}publicvoid setTicketNumber(String string) {

ticketNumber = string;

}publicvoid setTransactionType(int i) {

transactionType = i;


}//end of Ticket Class


//Queue class implement vector //basic queue functions, didn't paste here

// my main app
publicclass Simulation {
staticfinalint EXIT = 4;
staticint simClock = 0;

publicstaticvoid main(String[] args) throws IOException {
String token1, token2;
int queueNum;
if (args.length != 2) {



BufferedReader fileData = null; //File handle
int choice = 0;
int numQueue = (Integer.valueOf(args[1])).intValue(); // args 1 is the number of queues at the DMV
DMVQueue[] queues = new DMVQueue[numQueue];

fileData = openFile(args[0]); // open the file

StringTokenizer st;
// while ((choice = getMenu()) != EXIT) {
String textFromFile = readLineFromFile(fileData);
// read the first line in file
while (moreDataIn(textFromFile)) {
st = new StringTokenizer(textFromFile);

token1 = st.nextToken();

if (token1.equalsIgnoreCase("customer")) //is first word customer?


token2 = st.nextToken(); // read the number

queueNum = (Integer.valueOf(token2)).intValue(); //represent in which queue
// shouldthis customer be put in
// queues[0].enqueue(new Ticket()); // put new customer in receptionist queue, this is what i think we'r supose to do, i don't know


if (token1.equalsIgnoreCase("pause")) {

choice = getMenu(); //get keyboard input


if (token1.equalsIgnoreCase("skip")) {

simClock++; // Increment simulation Timer


if (token1.equalsIgnoreCase("Agent")) {


if (token1.equalsIgnoreCase("Receptionist")) {


textFromFile = readLineFromFile(fileData); // read next line

} //end (moreDataIn(textFromFile)


fileData.close(); //we are done, close the file

// queues.printQueue();

System.out.println("Simulation clock = " + simClock);// just a test

} //end Main

(example Input File)
Customer 5 //Time = 1 Eye_Exam
Customer 2 //Time = 2 Renew_License
Customer 5 //Time = 3 Eye_Exam
Customer 5 //Time = 4 Eye_Exam
Customer 5 //Time = 5 Eye_Exam
Receptionist //Time = 6
Agent //Time = 7 John_Smith
Receptionist //Time = 8
Receptionist //Time = 9
Skip //Time = 10
Skip //Time = 11
Receptionist //Time = 12
Customer 3 //Time = 13 Vehicle_Registration
Agent //Time = 14 John_Smith
Pause //Time = 15

any hints on even where i can find example of this round robin things would help. thanks i'm going to keep working on it maye it will come to me :)


This article has been dead for over six months. Start a new discussion instead.