-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added test and code. #33
base: master
Are you sure you want to change the base?
Conversation
job_seekers.times do | ||
waiting.enqueue("Worker ##{count}") | ||
count += 1 | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but with ruby you can do the following (which reads cleaner):
jobs_available.times do |count|
@workers.push("Worker ##{count+1}")
end
Figuring out how to use this same syntax for the waiting queue isn't trivial, but is similar.
end | ||
@waiting = Queue.new | ||
job_seekers.times do | ||
waiting.enqueue("Worker ##{count}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be @waiting
end | ||
|
||
def cycle | ||
|
||
# roll, fire, hire | ||
roll = rand(5) + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be @roll so that it's accessible through attr_reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I believe rand(5)
will give you a number 0-4.
Adding + 1
at the end will shift your range to 1-5.
I don't think it's possible for your solution to roll a 6.
proc { | ||
sim.cycle | ||
}.must_output(/HIRE: Worker #/) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests! Nice touch!
Stacks and QueuesWhat We're Looking For
OPTIONAL JobSimulation
Looks good! |
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation