Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question 开发者_运维问答The balance field won't update when AddBirthdayBonus
is called. Any help is appreciated.
public class class
{
private float balance;
private float bob;
public class(float amount, float bob)
{
balance = amount;
}
birthdate = birthday;
}
public void AddBirthdayBonus(float todayDate)
{
if (todayDate == bob)
{
balance += 5;
}
}
Something like this has more chances to work:
public class MyClass{
private float balance;
private float bob;
public MyClass(float balance, float bob)
{
this.balance = balance;
this.bob = bob;
}
public void AddBirthdayBonus(float todayDate)
{
if (todayDate == bob){
balance += 5;
}
}
}
Bob has no value here so you can't compare it with another variable, you should assign a value to it to be able to compare it with another variable
精彩评论