File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
src/main/java/com/example Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .example ;
2
+
3
+ import java .time .LocalDate ;
4
+ import java .time .format .DateTimeFormatter ;
5
+ import java .util .Date ;
6
+
7
+ public class AppIdades {
8
+ public static void main (String [] args ) {
9
+ System .out .println ("uobaaa" );
10
+
11
+ var cidadao01 = new Cidadao ();
12
+ cidadao01 .setDataNascimento (LocalDate .of (1992 , 04 , 1 ));
13
+ System .out .println (cidadao01 .idade ());
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ package com .example ;
2
+
3
+ import java .time .LocalDate ;
4
+
5
+ public class Cidadao {
6
+ private LocalDate dataNascimento ;
7
+
8
+
9
+ public LocalDate getDataNascimento (){
10
+ return dataNascimento ;
11
+ }
12
+
13
+ public void setDataNascimento (LocalDate dataNascimento ){
14
+ this .dataNascimento = dataNascimento ;
15
+ }
16
+
17
+ public int idade (){
18
+ return LocalDate .now ().getYear () - dataNascimento .getYear ();
19
+ }
20
+
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments