*Requested to be deleted.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
*Requested to be deleted.
Last edited by Chassy13; March 19th, 2014 at 09:40 PM.
How do you execute the code for testing? I don't see a main() method.
If you don't understand my answer, don't ignore it, ask a question.
The code hangs when I start its execution? There is no output.
If you don't understand my answer, don't ignore it, ask a question.
Here's what I get with that input:Here is the statement I use to automate input:Running: java.exe -cp . SingleServerQueueTest
Time updated by 2 time units and time is now 2.
No customer is being served at the present time of 2.
A customer entered system at time 2. Number waiting in queue is 0.
Time updated by 4 time units and time is now 6.
A customer entered system at time 6. Number waiting in queue is 1.
Time updated by 1 time unit and time is now 7.
A customer entered system at time 7. Number waiting in queue is 2.
Customer C1/T2 finished at time 7. Number waiting is 2.
Program Error!
1 error(s)stdin = new Scanner("T 2\nC\nA\nT 4\nA\nT 1\nA\nC\n"); //<<<<<<<<<<System.in);
Why is the last line wrong?
If you don't understand my answer, don't ignore it, ask a question.
Did the output from my version look like what you get?
Do the values in the Scanner class's constructor I posted work for you and give you the output showing the problem?
Why is the last line wrong?
If you don't understand my answer, don't ignore it, ask a question.
For testing you should put a String in the Scanner class's constructor like I showed earlier so everyone that tries testing will easily get the same results. I find typing in responses prone to error besides being a waste of time.
You need to add some debug output to show the status of the queue as the code executes to see what is happening.
If you don't understand my answer, don't ignore it, ask a question.