Modify the program below to accommodate any number of customers with a maximum of 10 customers allowed inside the premises at a time.
Make sure no error and running smooth in python program software.
import os
class PriorityQueue:
def __init__(self, size):
self.heap = [None] * size
self.n = 0
def __str__(self):
string = ""
for i in range(1, self.n):
string += str(self.heap[i]) + ', '
string += str(self.heap[self.n])
return string
def heapify(self, r):
left = 2 * r;
right = 2 * r + 1;
if left <= self.n="" and="" self.heap[left]=""> self.heap[r]:
largest = left
else:
largest = r
if right <= self.n="" and="" self.heap[right]=""> self.heap[largest]:
largest = right
if largest != r:
temp = self.heap[r]
self.heap[r] = self.heap[largest]
self.heap[largest] = temp
self.heapify(largest)
def build_heap(self):
for i in range(self.n // 2, 0, -1):
self.heapify(i)
def insert(self, value):
pnew = self.n + 1
self.heap[pnew] = value
while pnew > 1 and self.heap[pnew // 2] <>
self.heap[pnew] = self.heap[pnew // 2]
pnew = pnew // 2
self.heap[pnew] = value
self.n = self.n + 1
def delete_max(self):
max = self.heap[1]
self.heap[1] = self.heap[self.n]
self.n = self.n - 1
self.heapify(1)
return max;
def max(self):
return self.heap[1]
queue = PriorityQueue(10)
priority_number = 10
customers = []
customers_priorities = []
def menu():
choices = "1234"
print("======= MENU ========")
print("[1] Add Customer ")
print("[2] Get Customer ")
print("[3] Print Customers")
print("[4] Exit")
print("=====================")
option = input("Enter your choice :")
while True:
if option not in choices:
print("Error! Invalid Choice...")
option = input("Enter your choice :")
else:
return option
def get_customer_name(customers_priority):
for i in range(0, len(customers_priorities)):
if customers_priorities[i] == customers_priority:
return customers[i]
return None
while True:
choice = menu()
if choice == "1":
customers.append(input("Enter your name :"))
customers_priorities.append(priority_number)
queue.insert(priority_number)
priority_number -= 1
elif choice == "2":
customers_priority = queue.delete_max()
print("Priority Number : ", customers_priority)
print("Name : ", get_customer_name(customers_priority))
elif choice == "3":
print("Name Priority number")
for i in range(len(customers)):
print(customers[i], " ", customers_priorities[i])
else:
break
print("Thank you for using the application...")
=>=>