This commit is contained in:
2022-03-17 18:18:06 +08:00
parent 52c53c5be7
commit 6bf672bd5b
10 changed files with 631 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/*
* Explain:
* The check method is static because it is do not need to create an Start object.
*/
public class Start {
public static void main(String[] args) {
Student.testStudent();
Student stu = new Student(123);
System.out.println(check(stu) == "need coffee");
stu.fallAsleep();
System.out.println(check(stu) == "sweet dreams");
Chicken.testChicken();
}
/**
* check student sleeping. If student is sleeping, return "sweet dreams", if
* not, return "need coffee".
*
* @param stu. Student object
* @return String.
*/
public static String check(Student stu) {
if (stu.isSleeping()) {
return "sweet dreams";
} else {
return "need coffee";
}
}
}