Answered step by step
Verified Expert Solution
Link Copied!

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:
__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

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

x+n is in O(n2) O True O False

Answered: 1 week ago