Created
June 15, 2019 00:07
-
-
Save jay3ss/5641fa3de11129118dc2fae305135ba8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
class StackInterface(abc.ABC): | |
"""An abstract base class that defines a stack""" | |
@abc.abstractmethod | |
def is_empty(self): | |
"""Determines if the stack is empty | |
:return True if the stack is empty, False otherwise | |
""" | |
pass | |
@abc.abstractmethod | |
def peek(self): | |
"""Returns the top of the stack | |
:pre The stack isn't empty | |
:return The entry at the top of the stack | |
""" | |
pass | |
@abc.abstractmethod | |
def pop(self): | |
"""Removes the entry from the top of the stack | |
:post The entry at the top of the stack will be removed, if possible | |
:return True if removal was successful, False otherwise | |
""" | |
pass | |
@abc.abstractmethod | |
def push(self, entry): | |
"""Adds an entry to the top of the stack | |
:post The entry will be added to the top of the stack, if possible | |
:return True if addition was successful, False otherwise | |
""" | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment