Search:

Type: Posts; User: Norm

Page 1 of 2 1 2

Search: Search took 0.11 seconds; generated 54 minute(s) ago.

  1. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    The initial value of an int is 0. If it is not assigned a different value, its value will stay at 0.

    Read the API doc for the currentTimeMillis() method to see what value it returns.


    Use an...
  2. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    Don't call the System.currentTimeMillis() method in the constructor for the exit time. The exit time should be set when the customer object exits the wait queue by setting exit_time to...
  3. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    If the variable is public use an assignment statement to assign it the value returned by: System.currentTimeMillis();.
  4. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    What class is the getTime() method in and what does it return?
    What is the problem calling a method from inside a loop?

    The System class has a method that returns the PCs time.
  5. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    What happened to the Customer class's toString() method? See post#50.
  6. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    When the customer is added to the wait queue, set the customer's arrival time to the current time.
    When the customer is removed from the wait queue, compute the waiting time by subtracting the...
  7. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    Do you know what that is?


    That doesn't make any sense. How was it coded? Working with Station objects when Customer objects have the data???
    Customers wait in the queue. Customers are...
  8. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    I think its time to go back to the design and describe what you are trying to simulate.
    My design was for a company like a bank that had a number of tellers(I). Customers(II) arrive at a variable...
  9. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    Why is the cashiers an array of Station?

    Why is there a 10 in the for loop? That should be a variable defined at the top of the class.


    The array shouldn't be null. The slots in the array...
  10. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    There is a method that removes an element from the list.

    Use an assignment statement to assign a value to a slot in an array.
  11. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    Impossible and unrealistic.
  12. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    ??? The scaling of time means 3ms is used for 3sec
    What can happen in 3 seconds? That is not a reasonable time to do anything.

    There is no wait time if the customer goes directly to a cashier...
  13. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    The cashiers process Customers not Stations.

    Do you know how to use an array? Take a look at the tutorial: Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    What is...
  14. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    If the model is going to use clock time, the time the customer is added (and removed) could come from the System class's currentTimeMillis() method.

    Next try defining the cashiers array.
    Add code...
  15. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    The toString() method's DEFINITION is added to the Customer class. You don't call the method.
    The println() of the line object will call the toString() method and change this: [Customer@8955b34]...
  16. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    Now you need to add code to save the time the Customer object is added to the queue.

    And add a toString() method to the Customer class that returns the id number for the customer and the time the...
  17. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    I thought it was supposed to be a minimum of 10.

    Where is the class to hold the Customer's data? Things like time of arrival in queue and what cashier is doing the processsing and how much time...
  18. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    What code would you put in a Customer? I don't have any code in mine.


    No. The cashier slots are empty at the start of the simulation and then become available when the processing for a Customer...
  19. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    You can create an array of any datatype: primitives like int or objects like String or Customer.
    Customer[] cashiers; // define array for cashiers

    No. See post#22. The Customers are generated ...
  20. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    The queue would be in the main class. It would hold Customer class objects.

    What is the third class?


    The cashiers could be an array of Customer objects. The Customer in a slot would be the...
  21. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    Using the clock model: There would be one main class and a class for the customers, a class to handle the timer events. The main class would start a thread that would have a loop to generate x...
  22. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    Can you get more information from your tutor about this assignment? Both solutions I've been talking about involve classes and techniques that you have not studied yet.

    I'd scale it down farther....
  23. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    That's a completely separate problem. Don't mix it in with the rest of the code for now. Come back to it later.

    What is the array: list for? The customers should NOT be named. Give them...
  24. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    In the clock time model, the timers would be for the cashier processing.

    I can't see that you have the knowledge yet to write a clock time model.
    The event time model requires random numbers...
  25. Thread: Queue Simulation

    by Norm
    Replies
    78
    Views
    7,916

    Re: Queue Simulation

    This thread has a good description: http://www.javaprogrammingforums.com/object-oriented-programming/16861-multi-queue-simulation-theory.html

    I don't remember seeing any assignments like this one...
Results 1 to 25 of 36
Page 1 of 2 1 2