package br.net.venson;

import java.util.List;

class NormalIterator implements PlaylistIterator {
    private List<Song> songs;
    private int index = 0;

    public NormalIterator(List<Song> songs) {
        this.songs = songs;
    }

    public boolean hasNext() {
        return !songs.isEmpty();
    }

    public Song next() {
        index = (index + 1) % songs.size();
        return songs.get(index);
    }

    public boolean hasPrevious() {
        return !songs.isEmpty();
    }

    public Song previous() {
        index = (index - 1 + songs.size()) % songs.size();
        return songs.get(index);
    }

    public Song current() {
        return songs.get(index);
    }

    public Song first() {
        index = 0;
        return songs.get(index);
    }
}