Commit f04bdbb5 by Patryk Czarnik

ktoraGodzina i oblicz

parent f113ca2f
package hello; package hello;
import java.time.LocalDateTime;
import jakarta.jws.WebService; import jakarta.jws.WebService;
@WebService @WebService
...@@ -13,9 +15,18 @@ public class Usluga { ...@@ -13,9 +15,18 @@ public class Usluga {
return "Witaj " + imie; return "Witaj " + imie;
} }
// TODO dodaj dwie metody: public String ktoraGodzina() {
// - zwracanie bieżącego czasu return LocalDateTime.now().toString();
// - oblicz(int x, int y, String operacja) }
public int oblicz(int x, int y, String operacja) {
return switch (operacja) {
case "+" -> x + y;
case "-" -> x - y;
case "*" -> x * y;
case "/" -> x / y;
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