package at.spengergasse.urlaub.service;

import at.spengergasse.urlaub.domain.Urlaub;
import com.github.javafaker.Faker;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class UrlaubService {
    private final ArrayList<Urlaub> data;

    public UrlaubService() {
        data = new ArrayList<>(100);
        fillTestdata(100);
    }

    public void fillTestdata(int anz) {
        Urlaub u;
        Faker faker;

        faker = new Faker();
        for (int i=0; i<anz; i++) {
            u = new Urlaub(
                    faker.address().country(),
                    faker.address().cityName(),
                    faker.bool().bool(),
                    faker.number().randomDouble(2,600, 4000),
                    Urlaub.URLAUBART[faker.number().numberBetween(0, Urlaub.URLAUBART.length)]);
            data.add(u);
        }
    }

    @Override
    public String toString() {
        String erg;

        erg = "";
        for (Urlaub u : data) {
            erg += u.toString()+"\n";
        }
        return erg;
    }
}









