LineArrayBag
Assume you have the following class LineArrayBag that uses the Line class from Exercise 1.
LineArrayBag |
-data:Line[] -manyItems:int |
+LineArrayBag() +LineArrayBag(capacity:int) +add(element:Line):void +countOccurances(target:Line):int +grab(index:i):Line +remove(target:Line):void +size():int +max():int +toString():String |
-
Write the implementation for an iterator class for LineArrayBag. Be sure to include the iterator() method.
-
Write code (in driver’s main method) to use your iterator to display all the Lines in a LineArrayBag object.
-
Enable the enhanced for-loop by implementing the Iterable interface for the LineArrayBag class.
-
Write an enhanced for-loop (in driver’s main method) to display all the Lines in a LineArrayBag named myLines.
Trending now
This is a popular solution!
Step by step
Solved in 6 steps