There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:If you are simulating, you could loop from 0 to 600, and decide what to do each second
Junilu Lacar wrote:
fred rosenberger wrote:If you are simulating, you could loop from 0 to 600, and decide what to do each second
Or loop 10 times with each iteration representing a minute
Stefan Evans wrote:
Think about that one though. Is a minute enough granularity to determine which person goes to which teller?
Junilu Lacar wrote:Are you supposed to have a actual queue data structure here?
fred rosenberger wrote:does it RUN for 10 minutes, or are you SIMULATING a run of 10 minutes?
Stefan Evans wrote:I would actually start with creating a Teller object with a property indicating either how long it takes to serve a customer, or how many per minute they can handle. (I like the time to serve option as it provides a bit more flexibility in some respects, but it doesn't exactly match your spec)
You could then represent this scenario as an array of Tellers, and a Queue of customers.
Junilu Lacar wrote:
I think you guys might be complicating things too much. Does it matter which teller a person goes to? I'm pretty sure I've seen this problem before and all you really want to see is how fast the queue grows and shrinks -- which teller gets which person is irrelevant. But let's let the OP tell us what the goal is rather than speculate.
Mike Stein wrote:I don't know if I need to actually show which customer is going to which teller. I'm pretty sure the Prof. just wants to see the first 11 customers removed from the line every one minute and another 10 customers added to the line every minute. Of course, I could be wrong. I will have him specify exactly before I make more assumptions.
Junilu Lacar wrote:If that's the case, I would not even bother with a Teller object...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
OP wrote:the only thing I need this program to do is pop the first 11 customers off every minute, then display the contents of the queue
Junilu Lacar wrote:Taking this at face value, what role would the Teller and Bank object(s) have? I suppose you could have a Teller take a Queue reference and call the pop or remove method on it but what's the point? I can't think of anything useful that a Bank object would do to achieve the stated goal. One pitfall of object oriented programming is trying to model too much of the real world in your program; OOP is really about assigning responsibilities to appropriate abstractions, not about modeling the real world.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Junilu Lacar wrote:We could go back and forth on this but I think I'll hold off until the OP has resolved his questions and shown what he's done to make the grade.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Mike Stein wrote:All, I can't begin to express my gratitude for all of your contributions to this post.
I will be posting my code on Monday as the project is due on Sunday. What I have so far works, but it needs A LOT of improvement. I can't wait to see your feedback and suggestions after I post the code!
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |