Dec-29-2020, 02:33 PM
I am new to python and have a question regarding stacks as a container class. My class stack looks like this:
The task comes from a book but the solutions are no longer available as the website no longer exists. Now I would like to know how it works.
Example how the programm should work:
shall be the class Stack implemented above.
Thanks in advance for all the help!
class Stack: def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop()Now I want to use class stack as a container class without inheriting it.
class Taskmanger: def __init__(self): self.task = {} def newTask(self,t,p): def popTaskwithlowestPriority(self):I don't know how to do this. Maybe something like this:
stack = Stack("")but where?
The task comes from a book but the solutions are no longer available as the website no longer exists. Now I would like to know how it works.
Example how the programm should work:
task = Taskmanager() task.newTask("Clean the bathroom",1) task.newTask("buy Milk",5) task.newTask("watch TV",1) task.popTaskwithlowestPriority() "Clean the bathroom" task.popTaskwithlowestPriority() "watch TV"The container class for the tasks of a certain priority
shall be the class Stack implemented above.
Thanks in advance for all the help!