I have a bank class below. What is the best way to add amounts to any instance variable in any of the constructors to make it o when i add different amounts from 2 or more different classes it will update in a way that when i call the method it should print out the overall amount added between the variables placed of all the classes.
If you have a better method of doing such please tell.
public class Person
{
public double balance = 0.0;
public double happy = 0.0;
public double newBalance = 0.0;
public double newHappy = 0.0;
public Person(){
balance = 0;
happy = 0;
}
public double getPaid(double moneys){
newBalance = balance + moneys;
return newBalance;
}
public double getSpend(double moneys){
newBalance = balance - moneys;
return newBalance;
}
public double getHappy(double happys){
newHappy = happy + happys;
return newHappy;
}
public double getSad(double happys){
newHappy = happy - happys;
return newHappy;
}
}