StackAndQueue import MyStack.docx - from StackAndQueue import MyStack CircularQueue import random#Create a fast food simulator and see if you can

StackAndQueue import MyStack.docx - from StackAndQueue...

This preview shows page 1 - 4 out of 10 pages.

from StackAndQueue import MyStack, CircularQueue import random """ #Create a fast food simulator and see if you can optimize for max profit Loop for 100 turns each turn, there is a 1 in 3 chance a car drives up. track the turn # the car arrives the car in front of the line can order - they order 1-5 burgers and 1-5 fries randomly the cook can have 4 orders of fries and 4 burgers cooking at once. burgers take 3 minutes to make and fries take 2 minutes. You can have up to 5 extra burgers ready to serve, but they expire after 5 minutes ( track the turn # they are done being cooked if they go into the burger chute ). 8 orders of fries fit in the warmer at a time, but they are stacked on top of each other, and fries older than 5 minutes are stale and can't be served. Served burgers earn $1 and fries $.50 if a car has waited for more than 5 minutes, assume it drives off and the car behind it pulls up. """ class GoodBurger : TARGET_READY_FRIES = 1 TARGET_READY_BURGERS = 2 MAX_FRIES_COOKING = 4 FRY_COOK_TIME = 2 MAX_FRY_STACK_SIZE = 8 EARNING_PER_FRY = .5 TIMES_UNTIL_FRIES_ARE_GROSS = 5 MINUTES_UNTIL_CAR_DRIVES_OFF = 10 def __init__ (self): self .grease_pit_to_cook_fries_in = CircularQueue()
Image of page 1

Subscribe to view the full document.

self .cooktop = CircularQueue() self .fry_stack = MyStack() self .burger_chute = CircularQueue() self .drive_thru = CircularQueue() self .money_earned = 0 self .money_lost_to_stale_food = 0 self .turn_number = 0 self .potential_sales_lost = 0 random.seed( 100 ) def __str__ (self): return "Good Burger Report - Number of Turns: {} - Money Earned: $ {} - Money Lost to Food Waste: $ {} - Cost of potential sales from drives offs: $ {} " .format( self .turn_number, self .money_earned, self .money_lost_to_stale_food, self .potential_sales_lost ) def simulate (self, turns): for turn in range (turns): self .turn_number = turn self .check_grease_pit_for_done_fries() # 1 in 3 chance a car gets added to the drive_thru self .does_car_showup() # take the order from the front car self .take_front_car_order() # cook more things self .get_to_ready_targets() def check_grease_pit_for_done_fries (self): while not self .grease_pit_to_cook_fries_in.is_empty() \ and self .grease_pit_to_cook_fries_in.first() + GoodBurger. FRY_COOK_TIME <= self .turn_number: if len ( self .fry_stack) < GoodBurger. MAX_FRY_STACK_SIZE :
Image of page 2
self .fry_stack.push( self .turn_number) self .grease_pit_to_cook_fries_in.dequeue() else : # fries burn, throw away self .money_lost_to_stale_food -= GoodBurger. EARNING_PER_FRY self .grease_pit_to_cook_fries_in.dequeue()
Image of page 3

Subscribe to view the full document.

Image of page 4
  • Winter '19
  • JAMES
  • Automobile, The Order, Turn, Hamburger, The Cook

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes