Created
May 11, 2012 21:20
-
-
Save fabiancarlos/2662475 to your computer and use it in GitHub Desktop.
Pequena class de exemplo de incremento e decremento de um 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 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