File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
java-ejercicios/src/main/java/quick/platzi Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ package quick .platzi ;
2+
3+ import java .util .function .Function ;
4+ import java .util .function .Predicate ;
5+
6+ public class MathFunctions {
7+
8+ public static void main (String [] args ) {
9+ Function <Integer ,Integer > square = x -> x * x ;
10+ System .out .println (square .apply (5 ));
11+
12+ Persona persona = new Persona ("Froy" ,'M' ,23 );
13+ System .out .println (persona .isHombreAndMayorDeEdad ());
14+ }
15+
16+ static class Persona {
17+
18+ private String nombre ;
19+ private char sexo ;
20+ private int edad ;
21+ private Predicate <Persona > isHombreAndMayorDeEdad ;
22+
23+ public Persona (String nombre ,char sexo ,int edad ){
24+ this .nombre = nombre ;
25+ this .sexo = sexo ;
26+ this .edad = edad ;
27+ isHombreAndMayorDeEdad = persona -> persona .sexo == 'M' && persona .edad >= 18 ;
28+ }
29+
30+ public boolean isHombreAndMayorDeEdad () {
31+ return isHombreAndMayorDeEdad .test (this );
32+ }
33+ }
34+
35+
36+ }
You can’t perform that action at this time.
0 commit comments