Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Programming * A ferris wheel has a fixed number of cars arranged in a circle. * Each car may either be empty, or hold

 JAVA Programming * A ferris wheel has a fixed number of cars arranged in a circle. * Each car may either be empty, or hold a single object of type T. * At any time, one car is at the bottom of the wheel, * and all other cars are in the air. * Objects can be loaded or unloaded from the car at the bottom, * and cannot be loaded or unloaded from any other car. * The wheel can spin around to move a new car to the bottom. */ public class Q4FerrisWheel { /** * Create a FerrisWheel with the given number of cars. * * @param numberOfCars the number of cars in the FerrisWheel */ public Q4FerrisWheel(int numberOfCars) { // FIXME complete this constructor } /** * @return true if this ferris wheel is empty, that is, if * every car is empty */ public boolean isEmpty() { // FIXME complete this method return false; } /** * If the bottom car is empty, load the given object into the car * and return true; otherwise return false. * * @param obj the object to load into the car; must not be null * @return true if the object was loaded */ public boolean load(T obj) { // FIXME complete this method return false; } /** * If the bottom car is not empty, remove the object from the bottom * car and return it. * Otherwise, return null. * * @return the object that was in the bottom car, or null if no such object */ public T unload() { // FIXME complete this method return null; } /** * Spin this ferris wheel, moving all cars forward around the wheel by one * position (thereby changing the bottom car). * The last car becomes the first car, * the first car becomes the second car, and so on. */ public void spin() { // FIXME complete this method } /** * Check whether a given value is contained in this ferris wheel. * Specifically, returns true if value is not null and * an element e is contained in this ferris wheel such that e.equals(value). * * @param value the value to search for * @return true if the value is contained in this ferris wheel */ public boolean contains(T value) { // FIXME complete this method return false; } /** * Create a String representation of this ferris wheel. * Objects are listed in order around the wheel, starting with the bottom * car, then the car that is next in order to become the bottom car, and * so on ending with the car that is last in order to become the bottom * car. * Values in the wheel are separated by commas (without spaces). * Each value is converted to string as by {@link String#valueOf(Object)}. * If a car is empty (null), its value is represented by the empty string, * still including a comma to mark its place in the wheel. * For example, a wheel of five cars in which: * - the bottom car contains "b" * - the following car contains "c" * - the following car is empty * - the following car is empty * - the following car contains "a" * would be represented as "b,c,,,a". * A wheel of three cars where the bottom car contains "zz" and the other * cars are empty would be represented as "zz,,". * An empty wheel of seven cars would be represented as ",,,,,,". * * @return a String representation of this ferris wheel */ public String toString() { // FIXME complete this method return null; } } 

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

=+2 How does the preparation and support for each type of IE vary?

Answered: 1 week ago

Question

=+What is the extent of the use of each type of IE?

Answered: 1 week ago