Skip to content

Instantly share code, notes, and snippets.

@fabiancarlos
Created May 11, 2012 21:20
Show Gist options
  • Save fabiancarlos/2662475 to your computer and use it in GitHub Desktop.
Save fabiancarlos/2662475 to your computer and use it in GitHub Desktop.
Pequena class de exemplo de incremento e decremento de um valor
public class Conta{
private double saldo;
public Conta(double saldo){
this.saldo = saldo;
}
public void depositar(double valor){
this.saldo += valor;
}
public void sacar(double valor){
this.saldo -= valor;
}
public double getSaldo(){
return this.saldo;
}
/*--- executa canta|Saldo|Deposito|Saque --*/
public static void main(String[] args){
Conta contaComun = new Conta(40);
System.out.println("Saldo ~> " + contaComun.getSaldo());
contaComun.depositar(45);
System.out.println("Depositar ~> " + 45);
System.out.println("Saldo + depósito ~> " + contaComun.getSaldo());
contaComun.sacar(10);
System.out.println("Sacar ~> " + 10);
System.out.println("Saldo - saque ~> " + contaComun.getSaldo());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment