Advertisement
GieeF

Untitled

May 11th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import java.util.function.BiFunction;
  2.  
  3. public final class Zad3 {
  4. public static void main(String[] args) {
  5.  
  6. //Function<Integer, Integer, Integer> apply = (x, y) -> x * y;
  7.  
  8. BiFunction<Double, Double, Double> fun = (stawka,podstawa) -> stawka * podstawa;
  9.  
  10. Podatek podatek = new Podatek();
  11.  
  12. System.out.print(podatek.obliczPodatek(17, 1000, fun));
  13.  
  14. }
  15. }
  16.  
  17. @FunctionalInterface
  18. interface IPodatek {
  19. double obliczPodatek(double stawka, double podstawa, BiFunction<Double, Double, Double> fun);
  20. }
  21.  
  22. class Podatek implements IPodatek {
  23.  
  24. @Override
  25. public double obliczPodatek(double stawka, double podstawa, BiFunction<Double, Double, Double> fun) {
  26. return fun.apply(stawka, podstawa);
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement