import structure5.*; import java.util.Iterator; public class BIterator extends AbstractIterator { protected int n; protected int current; public BIterator(int n) { this.n = n; reset(); } public void reset() { current = 0; } public String next() { String nextBit = get(); current++; return nextBit; } public boolean hasNext() { return current < 32; } public String get() { int whichBit = 1 << current; boolean isSet = (n & whichBit) == whichBit; return isSet ? "1" : "0"; } }