/* * Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007) * Date: 2022-03-19 * Description: Cat class */ public class Cat extends Animal { /** * Constructor. Initialize the name and weight of the cat */ public Cat(String name, double weight) { super(name, weight); } /** * Feeding a cat adds 1.0 to its weight */ public void feed() { setWeight(getWeight() + 1.0); } /** * Test */ public static void testCat() { Cat c = new Cat("Meow", 2.0); System.out.println(c.getName() == "Meow"); System.out.println(c.getWeight() == 2.0); c.feed(); // The name is still the same but the weight increased by 1.0: System.out.println(c.getName() == "Meow"); System.out.println(c.getWeight() == 3.0); } }