In: Computer Science
Users may order one or more pizzas, where each pizza may be either: small, medium or large. Small pizzas cost $5, medium pizzas cost $8 and large pizzas cost $12. All pizzas come on a tomato base (for our pizza shop, this will be the only option), and will have the topping cheese by default, at no extra cost. Users may choose up to a maximum of four additional toppings (bringing the total to five) from the following list, where each topping adds an additional $1 to the price of the pizza: Bacon, Olives, Ham, Mushrooms, ITECH5403 – Comparative Programming Languages School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 2 of 4 Pineapple, Salami, Anchovies. A pizza order consists of an order for one or more pizzas, where each pizza has a size, and may optionally include a list of up to four additional toppings. Each pizza order must be marked as either to be collected or to be delivered. If the pizza is to be collected then the order requires a name and a phone number to be valid. If the pizza is to be delivered then a name, phone number and address are required to be valid. In addition, if the order total is less than $30 then an $8 delivery fee is added to the total. The application must be error tolerant and capable of accepting keyboard input to store a number of pizza orders in memory (they do not have to be persisted to file), as well as displaying an order summary which include details of all orders, including: The details of each pizza in the order, The total cost of the order, and The name, phone number and (if required) address of the person who made the order. Program code in LISP ?
Source Code:
from _operator import add
class Pizza :
def __init__(self, size,topping,orderType):
self.size = size
self.topping = topping
self.orderType = orderType
if __name__ == '__main__':
pizzaList = []
number = int(input("how many pizza ? "))
for i in range(0,number):
print("Please enter details for pizza : ",i+1)
size = input("pizza size Small Medium or Large [s,m,l] ? ")
topping = input("do you want extra topping [y,n] ? ")
toppingList = []
if topping=='y' or topping=='Y':
print("Please choose topping from the list")
bacon = input("Bacon [y,n] ? ")
if bacon=='y' or bacon=='Y':
toppingList.append("Bacon")
Olives = input("Olives [y,n] ? ")
if Olives=='y' or Olives=='Y':
toppingList.append("Olives")
Ham = input("Ham [y,n] ? ")
if Ham=='y' or Ham=='Y':
toppingList.append("Ham")
Mushrooms = input("Mushrooms [y,n] ? ")
if Mushrooms=='y' or Mushrooms=='Y':
toppingList.append("Mushrooms")
if len(toppingList)!=4:
Pineapple = input("Pineapple [y,n] ? ")
if Pineapple=='y' or Pineapple=='Y':
toppingList.append("Pineapple")
if len(toppingList)!=4:
Salami = input("Salami [y,n] ? ")
if Salami=='y' or Salami=='Y':
toppingList.append("Bacon")
if len(toppingList)!=4:
Anchovies = input("Anchovies [y,n] ? ")
if Anchovies=='y' or Anchovies=='Y':
toppingList.append("Anchovies")
orderType = input("Order will be collected or delivered [c,d] ? ")
myPizza = Pizza(size,toppingList,orderType)
pizzaList.append(myPizza)
tempCost = 0;
needDelivery = False
totalCost = 0;
for pizza in pizzaList :
if pizza.size=='s':
print("Pizza size : Small")
tempCost+=5;
elif pizza.size=='m':
print("Pizza size : Medium")
tempCost+=8;
elif pizza.size=='l':
print("Pizza size : Large")
tempCost+=12;
if len(pizza.topping)!=0:
tempCost+=len(pizza.topping);
print("Pizza has following extra topping")
for name in pizza.topping:
print(name,end=" ");
print()
if(pizza.orderType=='c'):
print("Pizza will be collected")
else:
print("Pizza will be delivered")
needDelivery = True
print("Pizza costs : ",tempCost)
totalCost+=tempCost;
print("------------------------------------------")
if needDelivery and totalCost<30:
print("Adding delivery charges $8")
totalCost+=8;
print("\nYour total bill is : ",totalCost)
name = input("Enter your name : ")
phoneNumber = input("Enter your phone number : ")
if needDelivery:
address = input("Enter your address : ")
print("Thank you "+name+" for choosing us")
if needDelivery:
print("Your pizza will be delivered at : "+address)
Output:
If you have any doubts, feel free to ask
Happy learning