Question: I ' m trying to output a certain number ( 7 0 0 0 ) , but it keeps returning the same number I put

I'm trying to output a certain number (7000), but it keeps returning the same number I put in. Am I missing something or did I not type something correctly? This is the code so far:
class UML_Lab_Driver {
public static void main(String[] args){
Person Bob = new Person("Bob");
Bob.deposit(9000);
Bob.withdraw(4000);
Bob.deposit(2000);
System.out.println(Bob.getAccountBalance());//expecting 7000
}
}
class Person{
private Account account;
private String name;
private int value;
public Person(String name){
this.name=name;
}
public String getName(){
return name;
}
public void deposit(int amt){
account = new Account(amt);
}
public void withdraw(int amt){
account = new Account(amt);
}
public int getAccountBalance(){
return value=account.getValue();
}
}
class Account{
private int value;
public Account(int value){
this.value=value;
}
public Account (Account p){
value=p.value;
}
public int withdraw(int amt){
value -= amt;
if(value <0){
System.out.println("EXCESS WITHDRAW ALERT.
You will only withdraw the amount equal to what was left in your account.");
value=0;
}
return value;
}
public int deposit(int amt){
value += amt;
return value;
}
public int getValue(){
return value;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!