Implement the Account class, knowing that:
a. When you create an account, your balance is zero.
b. It is only possible to extract an amount less than or equal to the balance in the account.
I must do it following this annex:
The problem is that when I follow the instructions of the exercise it does not work, or it goes empty for example when I call the deposit method, I do not get what I deposit, it appears "I deposit:".
This is the code you made:
public class Cuenta {
//Atributos
private String titular;
private double saldo;
//Constructor
public Cuenta() {
}
public Cuenta (String titular , double saldo_incial) {
this.titular=titular;
this.saldo = 0.0; // Cuando se crea una cuenta, su saldo es cero.
}
//Metodos
public String getTitular() {
return this.titular;
}
public void setTitular() {
this.titular= titular;
}
public double getSaldo() {
return this.saldo;
}
public String toString() {
return "Titular : "+ this.titular + " saldo : "+ this.saldo;
}
public void depositar(double cantidad) {
System.out.println("Se deposito : ");
}
public void retirar(double cantidad) {
if(cantidad<=saldo) {
System.out.println("Se extrae : ");
}
else {
System.out.println("Solo es posible extraer un importe menor o igual al saldo que se tenga en la cuenta" );
}
}
}
public class PruebaCuenta {
public static void main(String[] args) {
Cuenta cuenta1 = new Cuenta();
Cuenta cuenta2 = new Cuenta ("jose" , 10);
cuenta1.getSaldo();
cuenta2.depositar(14);
}
}