File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
src/main/java/com/example Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .example ;
2
+
3
+ public class Cliente {
4
+ private double renda ;
5
+ private char sexo ;
6
+ public char getSexo () {
7
+ return sexo ;
8
+ }
9
+ public void setSexo (char sexo ) {
10
+ if (sexo == 'M' || sexo == 'F' )
11
+ this .sexo = sexo ;
12
+ else System .out .println ("Sexo Invalido" );
13
+ }
14
+
15
+ public int getAnoNaescimento () {
16
+ return anoNaescimento ;
17
+ }
18
+ public void setAnoNaescimento (int anoNaescimento ) {
19
+ this .anoNaescimento = anoNaescimento ;
20
+ }
21
+ private int anoNaescimento ;
22
+ public double getRenda () {
23
+ return renda ;
24
+ }
25
+ public void setRenda (double renda ){
26
+ if (renda >= 0 )
27
+ this .renda = renda ;
28
+ else System .out .println ("A renda é imcompativel " );
29
+ }
30
+
31
+ }
Original file line number Diff line number Diff line change
1
+ package com .example ;
2
+
3
+ class CriancoClasse {
4
+ public static void main (String [] args ) {
5
+ System .out .println ("Criando Classes" );
6
+ System .out .println ();
7
+ Cliente cliente = new Cliente ();
8
+ cliente .setRenda (10000 );
9
+ cliente .setSexo ('F' );
10
+ cliente .setAnoNaescimento (1983 );
11
+ System .out .println ("Renda: " + cliente .getRenda ());
12
+ System .out .println ("Sexo: " + cliente .getSexo ());
13
+ System .out .println ("Ano de Nascimento: " + cliente .getAnoNaescimento ());
14
+
15
+ System .out .println ();
16
+
17
+ Cliente cliente2 = new Cliente ();
18
+ cliente2 .setRenda (5000 );
19
+ cliente2 .setSexo ('M' );
20
+ cliente2 .setAnoNaescimento (1984 );
21
+ System .out .println ("Renda: " + cliente2 .getRenda ());
22
+ System .out .println ("Sexo: " + cliente2 .getSexo ());
23
+ System .out .println ("Ano de Nascimento: " + cliente2 .getAnoNaescimento ());
24
+
25
+ }
26
+
27
+ }
You can’t perform that action at this time.
0 commit comments