所以我得到了这个问题.考虑具有标准操作集的Stack和Queue类.使用Stack和Queue类,在调用mysteryFunction之前调用mysteryFunction之前包含哪些项目?
这是代码:
def mysteryFunction(s, q):
q.enqueue('csc148')
q.enqueue(True)
q.enqueue(q.front())
q.enqueue('abstract data type')
for i in range(q.size()):
s.push(q.dequeue())
while not s.is_empty():
q.enqueue(s.pop())
if __name__ == '__main__':
s=Stack()
q=Queue()
#About to call mysteryFunction
#What are contents of s and q at this point?
mysteryFunction(s, q)
#mysteryFunction has been called.
#What are contents of s and q at this point?
我无法理解面向对象编程,因为我是这个主题的新手.是否有任何链接可以分解堆栈和队列以及它们的作用?