class Conta2{
protected double saldo;
public double getSaldo(){
return this.saldo;
}
public void deposita(double valor){
this.saldo += valor;
}
public void saca(double valor){
this.saldo -= valor;
}
public void multiplicador(double taxa){
this.saldo += this.saldo * taxa;
}
}
class ContaCorrente extends Conta2{
public void multiplicador(double taxa){
this.saldo += this.saldo * taxa * 2;
}
}
class ContaPoupanca extends Conta2{
public void multiplicador(double taxa){
this.saldo += this.saldo * taxa * 3;
}
public void deposita(double valor){
this.saldo += valor - 0.10;
}
}
class Atualiza{
private double saldoTotal = 0;
private double selic;
public void atualizador(double selic){
this.selic = selic;
}
public void roda(Conta2 gui){
System.out.println("=====================");
System.out.println("Saldo anterior :" + gui.getSaldo());
gui.multiplicador(this.selic);
System.out.println("Novo saldo :" + gui.getSaldo());
}
public double getSaldoTotal(){
return this.saldoTotal;
}
}
class Teste {
public static void main(String[] args){
Conta2 gui = new Conta2();
ContaCorrente pedro = new ContaCorrente();
ContaPoupanca lucas = new ContaPoupanca();
gui.deposita(1000);
pedro.deposita(1000);
lucas.deposita(1000);
Atualiza mostra = new Atualiza(0.01);
mostra.roda(gui);
mostra.roda(pedro);
mostra.roda(lucas);
System.out.println("=============================");
System.out.println("Saldo total :" + mostra.getSaldoTotal());
}
}
λ javac Conta2.java
Conta2.java:79: error: variable mostra is already defined in method main(String[]) double mostra = (0.01);