package galerie.model;

import javax.swing.*;

public class ImageList {
    private final String[] files;
    private int index = 0;

    public ImageList(String... files) {
        if (files == null || files.length == 0) {
            throw new IllegalArgumentException("Il faut au moins une image.");
        }
        this.files = files;
    }

    public Icon currentIcon() { 
        return new ImageIcon(files[index]); 
    }

    public void next() { 
        index = (index + 1) % files.length;
     }


    public void previous() { 
        index = (index - 1 + files.length) % files.length; 
    }

    public int size() { 
        return files.length;
     }

    public Icon iconAt(int i) { 
        return new ImageIcon(files[i]); 
    }
}
