Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class IteratorCala implements Iterator {
- private Integer currentPosition = 0;
- public boolean IsDone(){
- if(currentPosition + 1 == 10){
- return true;
- } else {
- return false;
- }
- }
- public Integer First(Integer[] tablica){
- //System.out.println(tablica[0]);
- if(IsDone() == false){
- return tablica[0];
- } else {
- throw new ArrayIndexOutOfBoundsException("Brak elementów w tablicy");
- }
- }
- public Integer Next(Integer[] tablica){
- if(IsDone() == true){
- throw new ArrayIndexOutOfBoundsException("Koniec tablicy");
- } else {
- //System.out.println(currentPosition);
- currentPosition++;
- return tablica[currentPosition];
- }
- }
- public Integer CurrentItem(Integer[] tablica){
- if(IsDone() == false){
- return tablica[currentPosition];
- } else {
- throw new ArrayIndexOutOfBoundsException("Koniec tablicy");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement