Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cajeroAutomatico;
- public class Cuenta
- {
- private int saldo;
- private boolean estado = true;
- public Cuenta()
- {
- this.saldo = 0;
- }
- public int getSaldo()
- {
- return this.saldo;
- }
- public void setSaldo(int saldo)
- {
- this.saldo = saldo;
- }
- public boolean isEstado()
- {
- return this.estado;
- }
- public void setEstado(boolean estado)
- {
- this.estado = estado;
- }
- public void ingresarDinero(int dinero)
- {
- this.saldo = this.getSaldo() + dinero;
- }
- public String sacarDinero(int dinero)
- {
- if(dinero > this.saldo || dinero < 0) return "Monto de dinero a extraer no permitido.";
- else
- {
- this.saldo -= dinero;
- return "Dinero extraido de la cuenta con éxito.";
- }
- }
- public boolean haySaldo()
- {
- if(this.saldo > 0) return true;
- else return false;
- }
- public int vaciarCuenta()
- {
- int vuelto = this.saldo;
- this.setSaldo(0);
- return vuelto;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement