Last active
September 13, 2017 14:15
-
-
Save brunoazevedomendonca/02021c2283ce06f12503f3e85fe88147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<ScrollView | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_margin="8dp" | |
android:orientation="vertical"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Tipo" | |
android:textSize="20sp"/> | |
<EditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:enabled="false" | |
android:id="@+id/tipo_conta" | |
android:layout_marginBottom="16dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Numero" | |
android:textSize="20sp"/> | |
<EditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:enabled="false" | |
android:id="@+id/numero_conta" | |
android:layout_marginBottom="16dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Titular" | |
android:textSize="20sp"/> | |
<EditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:enabled="false" | |
android:id="@+id/titular_conta" | |
android:layout_marginBottom="16dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Saldo" | |
android:textSize="20sp"/> | |
<EditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:enabled="false" | |
android:id="@+id/saldo_conta" | |
android:layout_marginBottom="16dp"/> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Limite" | |
android:textSize="20sp"/> | |
<EditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:enabled="false" | |
android:id="@+id/limite_conta" | |
android:layout_marginBottom="16dp"/> | |
</LinearLayout> | |
</ScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cliente { | |
String nome; | |
String sobrenome; | |
String cpf; | |
public Cliente(String nome){ | |
this.nome = nome; | |
} | |
public String getNome() { | |
return nome; | |
} | |
public void setNome(String nome) { | |
this.nome = nome; | |
} | |
public String getSobrenome() { | |
return sobrenome; | |
} | |
public void setSobrenome(String sobrenome) { | |
this.sobrenome = sobrenome; | |
} | |
public String getCpf() { | |
return cpf; | |
} | |
public void setCpf(String cpf) { | |
this.cpf = cpf; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Conta { | |
static int quantidadeDeContas = 0; | |
protected int numero; | |
protected Cliente titular; | |
protected double saldo; | |
protected double limite; | |
public Conta(int numero, Cliente titular, | |
double saldo, double limite){ | |
this.numero = numero; | |
this.titular = titular; | |
this.saldo = saldo; | |
this.limite = limite; | |
quantidadeDeContas++; | |
} | |
public int getNumero() { | |
return numero; | |
} | |
public void setNumero(int numero) { | |
this.numero = numero; | |
} | |
public Cliente getTitular() { | |
return titular; | |
} | |
public void setTitular(Cliente titular) { | |
this.titular = titular; | |
} | |
public double getSaldo() { | |
return this.saldo; | |
} | |
public void setSaldo(double saldo) { | |
this.saldo = saldo; | |
} | |
public double getLimite() { | |
return limite; | |
} | |
public void setLimite(double limite) { | |
this.limite = limite; | |
} | |
public String getTipo(){ | |
return "Conta"; | |
} | |
public static int getQuantidadeDeContas() { | |
return quantidadeDeContas; | |
} | |
public static void setQuantidadeDeContas(int quantidadeDeContas) { | |
Conta.quantidadeDeContas = quantidadeDeContas; | |
} | |
public void deposita(double valor) { | |
this.saldo += valor; | |
} | |
public void saca(double valor) { | |
if(this.saldo > valor) | |
this.saldo -= valor; | |
} | |
public void atualiza(double taxa) { | |
this.saldo += this.saldo * taxa; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContaCorrente extends Conta { | |
public ContaCorrente(int numero, Cliente titular, double saldo, double limite) { | |
super(numero, titular, saldo, limite); | |
} | |
@Override | |
public void deposita(double valor) { | |
this.saldo += valor - 0.10; | |
} | |
@Override | |
public void atualiza(double taxa) { | |
this.saldo += this.saldo * taxa * 2; | |
} | |
@Override | |
public String getTipo(){ | |
return "Conta Corrente"; | |
} | |
public void transferePara(ContaCorrente destino, double valor){ | |
this.saca(valor); | |
destino.deposita(valor); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContaPoupanca extends Conta { | |
public ContaPoupanca(int numero, Cliente titular, | |
double saldo, double limite) { | |
super(numero, titular, saldo, limite); | |
} | |
@Override | |
public void atualiza(double taxa) { | |
this.saldo += this.saldo * taxa * 3; | |
} | |
@Override | |
public String getTipo(){ | |
return "Conta Poupança"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.widget.TextView; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Cliente berg = new Cliente("Corre Berg"); | |
Conta contaBerg = new ContaCorrente(12345, berg, | |
1000, 1700); | |
contaBerg.deposita(500); | |
exibe(contaBerg); | |
} | |
private void exibe(Conta conta){ | |
TextView tipoConta = (TextView) findViewById(R.id.tipo_conta); | |
tipoConta.setText(String.valueOf(conta.getTipo())); | |
TextView numeroConta = (TextView) findViewById(R.id.numero_conta); | |
numeroConta.setText(String.valueOf(conta.getNumero())); | |
TextView titularConta = (TextView) findViewById(R.id.titular_conta); | |
titularConta.setText(String.valueOf(conta.getTitular())); | |
TextView saldoConta = (TextView) findViewById(R.id.saldo_conta); | |
saldoConta.setText(String.valueOf(conta.getSaldo())); | |
TextView limiteConta = (TextView) findViewById(R.id.limite_conta); | |
limiteConta.setText(String.valueOf(conta.getLimite())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment