Question: Assignment: Write a class named RollercoasterQueue with the following attributes: _ _ queue _ length that holds the number of people in the queue; _

Assignment: Write a class named RollercoasterQueue with the following attributes:
__queue_length that holds the number of people in the queue;
__ride_seats that holds how many people can board the ride at once;
__ride_length that holds how long the ride lasts.
The class has the following methods:
__init__ should accept the ride's seats and length as arguments. These should be used to initialize __ride_seats and __ride_length. It should also assign 0 to __queue_length;
board_ride should decrease __queue_length by at most __ride_seats and at least 0 each time it's called;
enqueue should increase __queue_length by 1 each time it's called;
length should return the current __queue_length.
After you have written the class, write some code that prompts the user for the ride's seats and length, create a RollercoasterQueue object using them and assign it to rc_queue, and then call enqueue 20 times. Then call the board_ride until the queue is empty. Display the length of the remaining queue after each ride has been boarded.
Note: Take a look at the following sample run. Make sure your prompts match with the ones displayed.
Sample Run (User inputs enclosed in <>)
How many people fit in one ride? <10>
How long is the ride, in minutes? <10>
10
0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!