a3 move to Question1

This commit is contained in:
2022-04-11 13:59:00 +08:00
parent 8ae38c9f2b
commit 8fe0ec8e12
7 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
/*
* 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);
}
}