Commit 7f6863d8 by Patryk Czarnik

dalszde operacje pierwszego webserwisu

parent 791a626f
...@@ -2,6 +2,8 @@ package hello; ...@@ -2,6 +2,8 @@ package hello;
import jakarta.jws.WebService; import jakarta.jws.WebService;
import java.time.LocalTime;
@WebService @WebService
public class PierwszaUsluga { public class PierwszaUsluga {
public String hello() { public String hello() {
...@@ -12,9 +14,18 @@ public class PierwszaUsluga { ...@@ -12,9 +14,18 @@ public class PierwszaUsluga {
return "Witaj " + imie; return "Witaj " + imie;
} }
// dodaj metody: public String ktoraGodzina() {
// ktoraGodzina - bez parametru, zwraca bieżący czas return LocalTime.now().toString();
}
// oblicz(liczba1, liczba2, operacja) - wykonuje perację arytmetyczną i zwraca wynik liczbowy public long oblicz(long liczba1, long liczba2, String operacja) {
return switch(operacja) {
case "+" -> liczba1 + liczba2;
case "-" -> liczba1 - liczba2;
case "*" -> liczba1 * liczba2;
case "/" -> liczba1 / liczba2;
default -> throw new IllegalArgumentException("nieznana operacja " + operacja);
};
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment