package serwisy;

import jakarta.jws.WebParam;
import jakarta.jws.WebResult;
import jakarta.jws.WebService;

import java.util.concurrent.ThreadLocalRandom;

@WebService
public class Usluga {

    @WebResult(name="powitanie")
    public String sayHello(@WebParam(name="imie") String imie) {
        return "Hello " + imie + "!";
    }

    @WebResult(name="student")
    public Student nowyStudent(
            @WebParam(name="first-name") String imie,
            @WebParam(name="last-name") String nazwisko,
            @WebParam(name="cnt") int ileOcen) {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        Student student = new Student(imie, nazwisko);
        for(int i = 0; i < ileOcen; i++) {
            student.dodajOcene(random.nextInt(2, 5));
        }
        return student;
    }
}
