# Setting the number of cats

• 2
• Locked
Sally Johnson used to work at the buffet at the Podunk intergalactic station on Terra, but she stopped upon reaching retirement age. Now she collects cats. Over the years, it has become difficult to control the number of purring creatures: cats reproduce rapidly. We won't solve this problem for Sally, but we will write a method that records the number of cats.
You can't complete this task, because you're not signed in.
Daniel
Level 9 , Vienna, Austria
4 May 2020, 18:00
Be careful what the last condition says. The keyword here is set, NOT increase. The passed integer sets the declared integer up. End. I did not pay attention and I set up the method to throw the number taken inside the variable, which increases the number, it doesn't just set the number up. What I did was "variable is variable + passedInteger "; Pay attention. :)
Level 9 , Chisinau, Moldova, Republic of
22 November 2019, 11:46
Here you can find the explanation: https://stackoverflow.com/questions/11664522/why-cant-we-use-this-keyword-in-a-static-method
AlasCaras
Level 4 , Corpus Christi, United States
11 March 2021, 20:30
that link is ligit
Sachin
Level 12 , Pune, India
22 November 2019, 05:45
The Cat class's setCatCount method must set the value of the catCount variable equal to the passed argument. jst read the last requirement you will know what to do. Cat c = new Cat(); c.setCatCount(5); you need to just assign pass value to static var.
John
Level 8 , United States
27 June 2019, 21:06
I don't see how this is different from the previous problem. If I send a value to setCatCount from 'main" like: public static void main(String[] args) { Cat cat = new Cat(); cat.setCatCount(4); The value of catCount in the setCatCount method is 4, but the value of catCount in the main method is still 0. I used a similar approach in the previous problem and it worked, but it's not working here. Using 'this." doesn't work.
John
Level 8 , United States
27 June 2019, 21:16
I got it to work using Cat.catCount per bri. But I don't know why this works. Can someone explain?
bri
Level 7 , Sevilla, Spain
27 January 2019, 13:54
<aybe this is a silly question, but: When should we know when to use this.blablabla and the overall class.blablabla? ex. this.catCount v.s. Cat.catCount?
Bryce Lindley
Level 9 , Olympia, United States
15 February 2019, 00:42
I believe you use this. when there is an argument in the method () " variable in the method parameters " Cat.catCount is calling the global variable static catCount(). Perhaps?
Thomas Ward
Level 4 , El Dorado Springs, United States
21 February 2019, 00:13
Could the keyword static be a factor?
GarBer
Level 6 , Anchorage, United States
22 May 2019, 14:18
I think it's when an object is NOT passed to the method. This is true for static methods (I think).