Janice H.#32
Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Overall not bad, but you have some issues and unfinished methods in Queue. I also suggest you not use puts unless the method's purpose is output. Instead raise an error or return a meaningful value.
Take a look at my comments and let me know any questions.
| @store[@back-1] = element | ||
| @back = (@back + 1) % @store.length # to get back to index 0 |
There was a problem hiding this comment.
you're having to do @back-1 because you have set @back to 1 in the first if in this method and you wrote two separate ifs. Converting if @front == @back into an elsif would make this a bit more straightforward.
| def dequeue | ||
| raise NotImplementedError, "Not yet implemented" | ||
| if @front == -1 && @back == -1 | ||
| puts 'queue is empty, sorry!' |
There was a problem hiding this comment.
I would raise an error here instead of puts.
| return | ||
| end | ||
| value = @store[@front] | ||
| @front = (@front + 1) % @store.length |
There was a problem hiding this comment.
You also need to check if the queue is now empty here.
| def empty? | ||
| raise NotImplementedError, "Not yet implemented" | ||
| return true if @front == -1 && @back == -1 |
There was a problem hiding this comment.
| return true if @front == -1 && @back == -1 | |
| return @front == -1 && @back == -1 |
Chris--Sorry, I didn't have much time this week and didn't quite finish this assignment. I will try to do more in the next few days and push any changes, but I thought it would be better to first submit what I have. Thanks.
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation