Question: Need to add an iterator, and the main functions. I believe that you need to add five functions and nested class definition. Please fulfill out

Need to add an iterator, and the main functions. I believe that you need to add five functions and nested class definition. Please fulfill out the code without changing anything that is posted below and explain why you picked those functions and how the nested class definition with the iterator work. Please show output that you have received.

// GoFIterator.java abstract class GoFIterator { abstract void first(); abstract void next(); abstract boolean isDone(); abstract int currentItem(); }

// IntegerBuffer.java public class IntegerBuffer { int data[]; int dataLength = 0; public IntegerBuffer(int capacity) { data = new int[capacity]; } public boolean add(int value) { if (dataLength < data.length) { data[dataLength] = value; ++dataLength; return true; } else return false; } public int add(int values[]) { int count = 0; for (int i = 0; i < values.length; ++i) if (add(values[i])) ++count; return count; } public static void main(String args[]) { int values[] = {23, 12, -6, 14, 0, 37, -26, 5, 11, -4, 16, 12, 8, -3, 6, -2}; IntegerBuffer ibuf = new IntegerBuffer(32);; ibuf.add(values); ibuf.add(values); System.out.println("Java"); /* // this section tests the iterator int column = 0; GoFIterator iter = ibuf.createIterator(); for (iter.first(); !iter.isDone(); iter.next()) { if (column >= 10) { System.out.println(); column = 1; } else ++column; System.out.format("%5d", iter.currentItem()); } System.out.println(); // end if iterator test */ } }

Output Java 23 12 -6 14 0 37 -26 5 11 -4 16 12 8 -3 6 -2 23 12 -6 14 0 37 -26 5 11 -4 16 12 8 -3 6 -2

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