Question
Given this code: public class IteratorApp { private void PrintAll(MyIterator myIter){ //code for printing ONE array } } int[] aList = {2,3,4,5,6,7,8,9}; double[] dList =
Given this code:
public class IteratorApp {
private void PrintAll(MyIterator myIter){
//code for printing ONE array
}
}
int[] aList = {2,3,4,5,6,7,8,9};
double[] dList = {1.2,2.3,3.4,4.5,5.6,6.7,7.8};
String[] slist = {"What", "me","worry?"};
public void run() {
MyIntIterator myIter = new MyIntIterator(aList);
MyDoubleIterator myDIter = new MyDoubleIterator(dList);
MyStringIterator mySIter = new MyStringIterator(slist);
PrintAll(myIter);
PrintAll(myDIter);
PrintAll(mySIter);
}
}
create an iterator for each array. All three iterators must share the same base type (that is, polymorphic). All iterators must implement First, Next, IsDone and CurrentItem operations.
Should have the following: main class, IteratorApp class, Iterator interface, MyIntIterator class, MyDoubleIterator class, MyStringIterator class.
OUTPUT should look like:
2
3
4
5
6
7
8
9
1.2
2.3
3.4
4.5
5.6
6.7
7.8
What
me
worry?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started