Files
oop/lab/lab4/Question3/Start.java
2022-03-17 18:18:06 +08:00

33 lines
693 B
Java

/*
* 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";
}
}
}