/* * Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007) * Date: 2022-04-11 * Description: European rabbit */ public class EuropeanRabbit extends Rabbit { /** * Constructor. * * @param name The name of the Rabbit. * @param weight The weight of the Rabbit. */ public EuropeanRabbit(String name, double weight) { super(name, weight); } /** * Constructor. With default weight 2.0 * * @param name The name of the Rabbit. */ public EuropeanRabbit(String name) { this(name, 2.0); } /** * Test. */ public static void testEuropeanRabbit() { // test first constructor Rabbit rabbit = new EuropeanRabbit("Bugs Bunny"); System.out.println(rabbit.getName() == "Bugs Bunny"); System.out.println(rabbit.getWeight() == 2.0); System.out.println(rabbit.isCookable() == true); // test second constructor Rabbit rabbit2 = new EuropeanRabbit("Daffy Duck", 3.0); System.out.println(rabbit2.getName() == "Daffy Duck"); System.out.println(rabbit2.getWeight() == 3.0); System.out.println(rabbit2.isCookable() == true); } }