level06.lesson08.task02

Add two static methods to the class Cat: int getCatCount() and setCatCount(int) using which you can get / change the number of cats (the variable catCount).

Can someone please post the solution to this question. Please help!!

asked 19 Aug '15, 07:22

Harshita%20Das's gravatar image

Harshita Das
111
accept rate: 0%


In the Method "public static int getCatCount()" you just have to return your static variable And in the method "public static void setCatCount(int catCount)" you have to set your static variable to catCount! Thats it!

link

answered 01 Jun '16, 09:51

Joschi's gravatar image

Joschi
1
accept rate: 0%

public class Cat {
    private static int catCount = 0;
    public Cat() {
        catCount++;
    }
    public static int getCatCount() {
        return catCount;
    }
    public static void setCatCount(int catCount) {
        Cat.catCount = catCount;
    }
}
link

answered 19 May, 12:46

Igor's gravatar image

Igor
112
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×2

Asked: 19 Aug '15, 07:22

Seen: 624 times

Last updated: 19 May, 12:46

Related questions