Commit f04bdbb5 by Patryk Czarnik

ktoraGodzina i oblicz

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