Write a program that tracks a drive through at Four Friends FriesHave a queue for the line of carsHave a stack of cooked fries for servingSimulate 60 minutes worth of time at the drive...

1 answer below »
The assignment has been done but I still can get to the answer.


Write a program that tracks a drive through at Four Friends Fries Have a queue for the line of cars Have a stack of cooked fries for serving  Simulate 60 minutes worth of time at the drive thru. Every minute, there is a 1/3 chance of a car showing up when a car gets to the front of the queue, it orders 1-6 orders of fries randomly the fry stack can have up to 8 fries at a time, track the 'time' they are done cooking.  if a fry is older than 10 minutes, it can't be served you can be cooking up to 4 orders of fries at a time in the frier, they take 2 minutes to cook so for each 'minute' figure out if a new car arrives in the drive through take any cooked fries out of the frier and add to the cooked fry stack ( with time done cooking ) take the order from the front car possibly add more fries to the frier to cook assume each order of fries costs $.5, and is sold for $1. track total profit/loss after 60 minutes import random import time class Fry: def __init__(self, cook_time): self.cook_time = cook_time class Car: def __init__(self, order_size): self.order_size = order_size def main(): # Start with an empty queue and stack queue = [] stack = [] # Track the time and profit current_time = 0 profit = 0 # Cook up to 4 orders of fries at a time frier_size = 4 frier = [] # A car has a 1/3 chance of arriving each minute arrival_chance = 1 / 3 # Each order of fries takes 2 minutes to cook fry_cook_time = 2 # Each order of fries costs $0.5 and is sold for $1 fry_cost = 0.5 fry_price = 1 while current_time < 60:="" current_time="" +="1" #="" check="" if="" a="" new="" car="" arrives="" if="" random.uniform(0,="" 1)="">< arrival_chance:="" order_size="random.randint(1," 6)="" queue.append(car(order_size))="" #="" remove="" any="" cooked="" fries="" from="" the="" frier="" and="" add="" them="" to="" the="" stack="" for="" fry="" in="" frier:="" fry.cook_time="" -="1" if="" fry.cook_time="=" 0:="" stack.append(fry)="" frier="[fry" for="" fry="" in="" frier="" if="" fry.cook_time="" !="0]" #="" cook="" more="" fries="" if="" there's="" room="" in="" the="" frier="" if="" len(frier)="">< frier_size:="" if="" len(queue)=""> 0 and len(stack) >= queue[0].order_size: new_fries = [] for i in range(min(frier_size - len(frier), queue[0].order_size)): fry = stack.pop() new_fries.append(Fry(fry_cook_time)) frier.extend(new_fries) # Serve the front car if their order is ready if len(queue) > 0 and len(stack) >= queue[0].order_size: order_size = queue.pop(0).order_size for i in range(order_size): stack.pop() profit += fry_price * order_size - fry_cost * order_size # Remove any fries that are older than 10 minutes stack = [fry for fry in stack if current_time - fry.cook_time <= 10] print("total profit after 60 minutes: $" + str(profit)) if __name__ == '__main__': main() 10]="" print("total="" profit="" after="" 60="" minutes:="" $"="" +="" str(profit))="" if="" __name__="=" '__main__':="">
Answered Same DayFeb 14, 2023

Answer To: Write a program that tracks a drive through at Four Friends FriesHave a queue for the line of...

Vedant answered on Feb 14 2023
27 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here