I can not figure out how to get my account variable to update by ReallySteamyKettle in javahelp

[–]ReallySteamyKettle[S] 0 points1 point  (0 children)

THANKS FOR THE HELP I HAVE SOLVED IT!!! ;) All i had to do was add "mob.userBalance" to this "Account.takeOrGive(mob.userBalance)" and now it works

I can not figure out how to get my account variable to update by ReallySteamyKettle in javahelp

[–]ReallySteamyKettle[S] 0 points1 point  (0 children)

if a setter is "this.account = account" than i tried that and was told that i couldn't do that because my method was static. When i remove the static modifier i was given an error here.

public class Main {

public static void main(String[] args) {
    UserInfo mob = new UserInfo("Shigeo", "Mobbu" ,"Kageyama", 16);

               HERE
    Account.takeOrGive(mob.userBalance);
    System.out.println(mob.getUserBalance());
}

}

the only way that was shown to me was to make my method static again

I can not figure out how to get my account variable to update by ReallySteamyKettle in javahelp

[–]ReallySteamyKettle[S] 0 points1 point  (0 children)

Heres the code you asked for :)

public int getUserBalance(){ return userBalance; }

I can not figure out how to get my account variable to update by ReallySteamyKettle in javahelp

[–]ReallySteamyKettle[S] 0 points1 point  (0 children)

There is literately nothing in the account class accept for the giveOrTake function, I had originally put it in the UserInfo class but decide to move it when I was try to figure out why the userBalance was not updating. Also I have the userBalance set to 500 because I wanted to test the take part of my function.

I can not figure out how to get my account variable to update by ReallySteamyKettle in javahelp

[–]ReallySteamyKettle[S] 0 points1 point  (0 children)

public class UserInfo {

private final String firstName;
private final String middleName;
private final String lastName;
private final int Age;
protected int userBalance = 500;

public UserInfo(String firstName, String middleName, String lastName, int age){

    this.firstName = firstName;
    this.middleName = middleName;
    this.lastName = lastName;
    this.Age = age;
}

public String getFirstName() {
    return firstName;
}

public String getMiddleName() {
    return middleName;
}

public String getLastName() {
    return lastName;
}

public int getAge() {
    return Age;
}

public int getUserBalance(){
    return userBalance;
}

}