Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class RollercoasterQueue: def _ _ init _ _ ( self , ride _ seats, ride _ length ) : self. _ _ ride _ seats

class RollercoasterQueue:
def __init__(self, ride_seats, ride_length):
self.__ride_seats = ride_seats
self.__ride_length = ride_length
self.__queue_length =0
def board_ride(self):
if self.__queue_length = self.__ride_seats:
self.__queue_length =0
else:
self.__queue_length -= self.__ride_seats
def enqueue(self):
self.__queue_length +=1
def length(self):
return self.__queue_length
# Sample run code
def main():
ride_seats = int(input("How many people fit in one ride? "))
ride_length = int(input("How long is the ride, in minutes? "))
rc_queue = RollercoasterQueue(ride_seats, ride_length)
# Enqueue 20 people
for _ in range(20):
rc_queue.enqueue()
print(f"Queue length after enqueue: {rc_queue.length()}")
# Board ride until the queue is empty
while rc_queue.length()>0:
rc_queue.board_ride()
print(f"Queue length after boarding: {rc_queue.length()}")
if __name__=="__main__":
main()
It looks like you did not store your instance in 'rc_queue'.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

State the importance of control

Answered: 1 week ago