//******************************************************************** // ParamPassTest.java // To test passing primitive data as parameters //******************************************************************** public class ParamPassTest { public static void main (String args[]) { int param = 3; addOne(param); System.out.println("main param is " + param); } public static void addOne(int p) { p = p + 1; System.out.println("addOne param is " + p); } } //******************************************************************** // Cat.java // Used in PassByValue.java //******************************************************************** public class Cat { private float weight; private int age; private boolean isFriendly; public Cat() { weight = 3.8f; age = 2; moodSwing(); } public void moodSwing() { isFriendly = ((int)(Math.random()*2) == 0); } public String toString() { String sWeight = "I weight " + weight + " kg.\n"; String sAge = "I'm " + age + " years old.\n"; String sFriendly = (isFriendly)? "I'm the nicest cat in the world." : "One more step and I'll attack."; return (sWeight+sAge+sFriendly); } public float eat(float food) { weight += food; System.out.println("it wasn't Fancy Feast's seafood fillet..."); wail(); return weight; } public void wail() { System.out.println("Miiiiaaawwwwwww!"); moodSwing(); } public int getAge() { return age; } public void birthday() { age++; for (int i=0; i