Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package e2;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Spliterator;
- import java.util.function.Consumer;
- public class Rebote<String> extends TVRealityList<String> implements Iterator<String>{
- int pos= 0;
- int k=3;
- int k2=k;
- boolean rebotando = false;
- public Rebote(List<String> lista, boolean circular){
- super(lista, circular);
- }
- int tamanoOriginal= lista.size();
- @Override
- public boolean hasNext() {
- if (lista.size()>1){
- return true;
- } else return false;
- }
- @Override
- public String next() {
- int poscorrecta;
- if(pos%lista.size()==0){
- rebotando=true;
- }
- if (!rebotando) {
- pos++;
- return lista.get(pos%lista.size());
- }else{
- pos--;k2--;
- if(k2==0){
- k2=k;
- rebotando=false;
- }
- return lista.get(pos%lista.size());
- }
- }
- @Override
- public void remove() {
- Iterator.super.remove();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement