Question: Help pl XU 1 1 s This problem requires that you write a new class called FoodShippingIterator to help manage food that need to be

"Help pl XU11 s
This problem requires that you write a new class called FoodShippingIterator to help manage food that need to be shipped to different stores across the country. The constructor for this class should take an array of Double references as its only argument. The values in this array represent the weights of produce that need shipping. Have this class implement the java.util.Iterator interface to return these Double weights. However, to account for the weight of packaging, add +0.1 to each of the weights returned by your class's next method (rather than returning exactly the values stored in the provided array). To demonstrate that your class works, add one static test method to your class that takes no arguments, and returns a boolean value: true when the test passes and false otherwise. You can name this method whatever you would like. This test method should create a new FoodShippingIterator with a specific array of weights, and then compute and check the sum of all weights returned as a result of calling next() until hasNext() becomes false. You are welcome (but not required) to include a main method to try calling this test method from. Feel free to add any private instance field you may need to implement your FoodShippingIterator class."

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 Programming Questions!