The secret CodeGym center has entered into an agreement with cat breeders to supply them with applications. In particular, as beginning programmers study getters and setters, they write a cat-counting program for cat lovers. Your time has come: Create a Cat class with static methods that you will use to get or change the number of cats.
Static methods for cats
- 2
Locked
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Mitesh Shah
30 December 2019, 10:54
Why does the setCatCount methoud require the variable to be set using Cat.catCount while the getCatCount method can return the value by calling the catCount variable without the Cat. in front of it?
+2
andy 6473
19 June 2020, 04:19
If we write
public static void setCatCount(int catCount) {
//write your code here
catCount = catCount;
}
then catCount becomes the local variable of the method setCatCount.
That is the reason we use Cat.catCount , to access the static variable . since method cannot access the static method directly;
0