day06-面向对象-属性和行为的使用

This commit is contained in:
2026-01-17 16:11:04 +08:00
parent 8e96df12d8
commit aac8e4ceec
2 changed files with 44 additions and 7 deletions

View File

@@ -23,16 +23,16 @@ public class Student {
//吃饭
public void eat(String food) {
System.out.println("学生在吃饭,吃"+food);
System.out.println(name+"学生在吃饭,吃"+food);
}
//睡觉
public void sleep() {
System.out.println("学生在睡觉");
System.out.println(name+"学生在睡觉");
}
//学习
public void study(String book) {
System.out.println("学生在学习,学"+book);
System.out.println(name+"学生在学习,学"+book);
}
}