Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class RollercoasterQueue: def _ _ init _ _ ( self , ride _ seats, ride _ length ) : self. _ _ ride _ seats
class RollercoasterQueue:
def initself rideseats, ridelength:
self.rideseats rideseats
self.ridelength ridelength
self.queuelength
def boardrideself:
if self.queuelength self.rideseats:
self.queuelength
else:
self.queuelength self.rideseats
def enqueueself:
self.queuelength
def lengthself:
return self.queuelength
# Sample run code
def main:
rideseats intinputHow many people fit in one ride?
ridelength intinputHow long is the ride, in minutes?
rcqueue RollercoasterQueuerideseats, ridelength
# Enqueue people
for in range:
rcqueue.enqueue
printfQueue length after enqueue: rcqueue.length
# Board ride until the queue is empty
while rcqueue.length:
rcqueue.boardride
printfQueue length after boarding: rcqueue.length
if namemain:
main
It looks like you did not store your instance in rcqueue'.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started