31 lines
667 B
Java
31 lines
667 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");
|
|
}
|
|
|
|
/**
|
|
* 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";
|
|
}
|
|
}
|
|
}
|