Make a static setter for numOfball
Example:
public static void main(String[] args) {
Book.setTitle("Test");
}
Type: Posts; User: Chris.Brown.SPE
Make a static setter for numOfball
Example:
public static void main(String[] args) {
Book.setTitle("Test");
}
You are setting your static variable in the constructor. This is wrong unless you have some sort of justification for it. Can you confirm you understand this error?
This is definitely because you are setting the numOfballs in your constructor for Ball. You are resetting it to 10 with every object. It should be set once at the beginning of the program.
The problem is that you're setting the value of numOfBall in your constructor for the Ball class. This is going to reset your static variable each time. You really shouldn't set the value of static...