/* * Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007) * Date: 2022-04-11 * Description: Mammal class */ public class Mammal { /** * Name of the mammal */ private String name; /** * Constructor * * @param name * name of the mammal */ public Mammal(String name) { this.name = name; } /** * Get the name of the mammal * * @return name of the mammal */ public String getName() { return name; } /** * Whether the mammal is can be cooked. * Some mammals can be cooked and some mammals cannot be cooked so for safety * reason the isCookable method just prints a message "Do not cook this!" and * returns false. * * @return false */ public boolean isCookable() { System.out.println("Do not cook this!"); return false; } /** * Test. */ public static void testMammal() { Mammal mammal = new Mammal("Mammal 1"); System.out.println(mammal.getName() == "Mammal 1"); System.out.println(mammal.isCookable() == false); } }