Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added test and code. #33

wants to merge 1 commit into from

Conversation

MonalisaC
Copy link

Stacks and Queues

Thanks for doing some brain yoga. You are now submitting this assignment!

Comprehension Questions

Question Answer
What is an ADT? Abstract data type model where data is classified based on behaviour.
Describe a Stack lStack is an ADT that uses last in first out behaviour.
What are the 5 methods in Stack and what does each do? push- which adds an element to the collection, pop - which removes the most recently added element that was not yet removed. If empty - returns true if nothing is in stack , top - returns the value of item on top of stack but does not remove, size - returns how many items are in the stack
Describe a Queue Queue is an ADT that use first in first out method.
What are the 5 methods in Queue and what does each do? addition of entities to the rear terminal position, known as enqueue, and removal of entities from the front terminal position, known as dequeue. If empty - returns true if nothing is in stack , top - returns the value of item on top of stack but does not remove, size - returns how many items are in the stack
What is the difference between implementing something and using something? implementing is like defining Class and using is like using class method by doing self.

OPTIONAL JobSimulation

Question Answer
Did you include a sample run of your code as a comment?

job_seekers.times do
waiting.enqueue("Worker ##{count}")
count += 1
end

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}")

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests! Nice touch!

@sudocrystal
Copy link

Stacks and Queues

What We're Looking For

Feature Feedback
Implementation of Stack looks complete yes
Implementation of Queue looks complete yes

OPTIONAL JobSimulation

Extension Feedback
Does the code solve the problem to specification? mostly - just misses @roll
Is the code easy to follow? yes
Does the output look good? yes
Were provided variables and methods used appropriately and not altered in name or definition? yes
Were any new variables and/or methods made private to the class? n/a

Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants