Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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