I am trying to enqueue 3 people in the list to display the results for each person with all their names at the top but was only able to achieve one result without any names:
Contacting the following
Phone answered: Yes
Booked an appointment: No
Reshedule an appointment again.
I want to make the output to display the all their names and 3 outputs, one for each person from the information stored inside 'names' , and each name to not appear twice.
I want to use a queue to prioritize them according to the list, so I'm trying to put them in order. the if and elif are conditions which will fall into either category depending on the random generator. Now, it is just that the method to include the names inside is not defined.
Code
import random
class Queue:
def __init__(self):
self.container = []
def isEmpty(self):
return self.size() == 0
def enqueue(self, item):
self.container.append(item)
def dequeue(self):
self.container.pop(0)
def size(self):
return len(self.container)
def peek(self) :
return self.container[0]
names = ["Alvin", "James", "Peter"]
# Enqueuing
q = Queue()
q.enqueue(random.choice(names))
# Dequeuing and Printing
print("Contacting the following:\n" + "\n".join(q.container)) # unsure about this
for i in range(q.size()):
answered = random.randint(0,1)
booked = random.randint(0, 1)
if(answered == 1 and booked == 1):
print("Now Calling -" + (q.names)) # unsure about this
print("Phone answered: Yes")
print("Booked an appointment: Yes")
print("Booking successful.")
elif(answered==1 and booked==0):
print("Now Calling -" + (q.names)) # unsure about this
print("Phone answered: Yes")
print("Booked an appointment: No")
print("Reshedule an appointment again.")
elif(answered == 0):
print("Now Calling -" + (q.names)) # unsure about this
print("Phone answered: No")
print("Reshedule a callback.")
q.dequeue()
Example desired output:
Contacting the following
Alvin
James
Peter
Now Calling - James
Phone answered: No
Reshedule a callback.