-
Notifications
You must be signed in to change notification settings - Fork 41
Fire-Blaine #28
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
base: master
Are you sure you want to change the base?
Fire-Blaine #28
Conversation
CheezItMan
left a comment
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.
You got it! Nice work Blaine, this works. Well done.
| @@ -1,19 +1,23 @@ | |||
| class Stack | |||
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.
👍
| def empty? | ||
| raise NotImplementedError, "Not yet implemented" | ||
| # return @front == -1 | ||
| return @store.all?{ |e| e.nil? } | ||
| 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.
Why not instead check to see if front and back are both 0?
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.
Honestly, didn't think of it. All I knew was I wanted to make sure the list was empty and I was getting errors because of nil so I googled for a fix. :-(
| elsif self.empty? | ||
| @front = 0 | ||
| @back = 0 |
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.
But if the Queue is empty, the back and front are already set to zero.
|
|
||
| end | ||
|
|
||
| def dequeue |
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.
👍
| return value | ||
| end | ||
|
|
||
| def front |
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.
👍
| return @store.all?{ |e| e.nil? } | ||
| end | ||
|
|
||
| def to_s |
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.
👍
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation