-
Notifications
You must be signed in to change notification settings - Fork 63
Ana Gabriele - Cedar c16 #49
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?
Conversation
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.
✨🌸 Nice work, Ana. Please check your implementation of front
for the Queue
class. I also left some minor style suggestions, but overall good work. Let me know what questions you have.
🟢
""" | ||
pass | ||
if self.size == self.buffer_size: | ||
raise QueueFullException('This will break it') |
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.
Small suggestion: When raising an exception, it's helpful to give a description of why the code is breaking
raise QueueFullException('This will break it') | |
raise QueueFullException('Queue full') |
Raises a QueueFullException if all elements | ||
In the store are occupied | ||
returns None | ||
""" |
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.
✨
# find element in the store | ||
# First in first out | ||
if self.size == 0: | ||
raise QueueEmptyException('This will break it') |
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.
Same thing as above with the Exception here ⬆️
""" Removes and returns an element from the Queue | ||
Raises a QueueEmptyException if | ||
The Queue is empty. | ||
""" |
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.
✨
pass | ||
|
||
if self.store[self.front]: | ||
return self.store[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.
The current tests don't cover front
which is why you may not have caught this.
return self.store[0] | |
return self.store[self.front] |
[3, 4, 7] | ||
Starting with the front of the Queue and | ||
ending with the rear of the Queue. | ||
""" |
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.
✨
pass | ||
|
||
self.store.add_last(element) | ||
return element |
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.
Per the specification, this function should return None
return element |
if not self.store: | ||
raise StackEmptyException("List is empty") | ||
|
||
return self.store.remove_last() |
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.
Again, per the function specification, this method should return None
return self.store.remove_last() | |
self.store.remove_last() |
And False otherwise | ||
""" | ||
pass | ||
return self.store.empty() |
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.
✨
ending with the bottom of the Stack. | ||
""" | ||
pass | ||
values = [] |
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.
✨ Yes, this works! You could also take advantage of the str
method in the LinkedList
class
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation