Write code in the addNewCat method to increase the number of cats by 1 each time it is called.
The variable catCount corresponds to the number of cats. The Cat class must have only one catCount variable. The variable catCount must be a static int, have a private access modifier, and be initialized to zero. The Cat class must have two methods: addNewCat and main. The Cat class's addNewCat method should increase the number of cats by 1.
Requirements:
public class Cat { private static int catCount = 0; public static void addNewCat() { int cat= catCount++; System.out.println(cat); //write your code here } public static void main(String[] args) { addNewCat(); } }
Here's a second task I thought I understood this but maybe not. I'm not really sure about object creation and object referencing. I don't know why I feel lke I understood it a few months age.
Finish writing the code of the setName method so that it sets the value of private String fullName to the value of the local String variable fullName. private String fullName; public void setName(String firstName, String lastName) { String fullName = firstName + " " + lastName; this.fullName= fullName; //write your code here } public static void main(String[] args) { } }
















