123 4 567120 8 9 11 12 class Queue: def __init__(self): self.a_in = [] self.a_out = [] def enqueue(self, d): self.a_in.append(d) def dequeue(self): if (self.a_out == []): for d in self.a_in: self.a_out.append(d) self.a_in = [] return self.a_out.pop(0)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 21SA
icon
Related questions
Question

Given the code below, insert the docstrings to
properly document the class and all its methods.
You will need to explain the code considering that the
documentation reader will need to understand the
code enough to provide maintenance.

123
4
567120
8
9
11
12
class Queue:
def __init__(self):
self.a_in = []
self.a_out = []
def enqueue(self, d):
self.a_in.append(d)
def dequeue(self):
if (self.a_out == []):
for d in self.a_in:
self.a_out.append(d)
self.a_in = []
return self.a_out.pop(0)
Transcribed Image Text:123 4 567120 8 9 11 12 class Queue: def __init__(self): self.a_in = [] self.a_out = [] def enqueue(self, d): self.a_in.append(d) def dequeue(self): if (self.a_out == []): for d in self.a_in: self.a_out.append(d) self.a_in = [] return self.a_out.pop(0)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage