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:
queuelength that holds the number of people in the queue;
rideseats that holds how many people can board the ride at once;
ridelength 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 rideseats and ridelength. It should also assign to queuelength;
boardride should decrease queuelength by at most rideseats and at least each time it's called;
enqueue should increase queuelength by each time it's called;
length should return the current queuelength.
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 rcqueue, and then call enqueue times. Then call the boardride 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?
How long is the ride, in minutes?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
