[SOLVED] Write a new class called FoodShippingIterator

25.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

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.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.