forked from abhi1540/PythonConceptExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionstobetested.py
More file actions
42 lines (29 loc) · 844 Bytes
/
Functionstobetested.py
File metadata and controls
42 lines (29 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Queue:
def __init__(self):
self.inbox = Stack()
self.outbox = Stack()
def is_empty(self):
return (self.inbox.is_empty() and self.outbox.is_empty())
def enqueue(self, data):
self.inbox.push(data)
def dequeue(self):
if self.outbox.is_empty():
while not self.inbox.is_empty():
popped = self.inbox.pop()
self.outbox.push(popped)
return self.outbox.pop()
class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def push(self, data):
self.items.append(data)
def pop(self):
return self.items.pop()
class Product(object):
def __init__(self, x, y):
self.x = x
self.y = y
def mul(self):
return self.x * self.y