File tree 4 files changed +37
-2
lines changed 4 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 21
21
22
22
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23
23
hs_err_pid *
24
+ /bin /
Original file line number Diff line number Diff line change 1
1
package model ;
2
2
3
+ import java .util .ArrayList ;
4
+
3
5
public class Cliente {
4
6
/**
5
7
* O nome do cliente.
@@ -15,7 +17,7 @@ public class Cliente {
15
17
/**
16
18
* A conta do cliente.
17
19
*/
18
- private Conta conta ;
20
+ private ArrayList < Conta > contas = new ArrayList <>() ;
19
21
20
22
/**
21
23
* Construtor.
@@ -24,8 +26,20 @@ public class Cliente {
24
26
* @param sobrenome
25
27
*/
26
28
public Cliente (Conta conta , String nome , String sobrenome ) {
27
- this .conta = conta ;
29
+ this .addConta ( conta ) ;
28
30
this .nome = nome ;
29
31
this .sobrenome = sobrenome ;
30
32
}
33
+
34
+ public ArrayList <Conta > getConta () {
35
+ return this .contas ;
36
+ }
37
+
38
+ public String getNome () {
39
+ return this .nome ;
40
+ }
41
+
42
+ public void addConta (Conta conta ) {
43
+ this .contas .add (conta );
44
+ }
31
45
}
Original file line number Diff line number Diff line change @@ -21,4 +21,12 @@ public Conta(Agencia agencia, String numero) {
21
21
this .agencia = agencia ;
22
22
this .numero = numero ;
23
23
}
24
+
25
+ public Agencia getAgencia () {
26
+ return this .agencia ;
27
+ }
28
+
29
+ public String getNumero () {
30
+ return this .numero ;
31
+ }
24
32
}
Original file line number Diff line number Diff line change 1
1
package view ;
2
2
3
+ import model .Agencia ;
4
+ import model .Cliente ;
5
+ import model .Conta ;
6
+
3
7
public class App {
4
8
5
9
public static void main (String [] args ) {
@@ -8,6 +12,14 @@ public static void main(String[] args) {
8
12
System .out .println ("+------------------------------+" );
9
13
System .out .println ("| 1. Criar Cliente |" );
10
14
System .out .println ("+------------------------------+" );
15
+
16
+ Agencia agencia = new Agencia ();
17
+ Conta conta = new Conta (agencia , "1234" );
18
+ Conta conta1 = new Conta (agencia , "4321" );
19
+ Cliente cli = new Cliente (conta , "NomeCliBoladao" ,"SobrenomeBoladao" );
20
+ System .out .println ("Nome: " + cli .getNome () + " Numero Agencia: " + cli .getConta ().get (0 ).getNumero ());
21
+ cli .addConta (conta1 );
22
+ System .out .println ("Nome: " + cli .getNome () + " Numero Agencia: " + cli .getConta ().get (1 ).getNumero ());
11
23
}
12
24
13
25
}
You can’t perform that action at this time.
0 commit comments