1 changed files with 0 additions and 32 deletions
@ -1,32 +0,0 @@ |
|||||
// Student.java
|
|
||||
public class Student { |
|
||||
// 成员属性
|
|
||||
private int studentId; |
|
||||
private String name; |
|
||||
private double score; |
|
||||
|
|
||||
// 构造方法(用于创建对象时给属性赋值)
|
|
||||
public Student(int studentId, String name, double score) { |
|
||||
this.studentId = studentId; |
|
||||
this.name = name; |
|
||||
this.score = score; |
|
||||
} |
|
||||
|
|
||||
// study() 方法
|
|
||||
public void study() { |
|
||||
System.out.println(name + "(学号:" + studentId + ")正在学习,当前成绩:" + score); |
|
||||
} |
|
||||
|
|
||||
// 可选:getter/setter 方法(用于访问/修改私有属性)
|
|
||||
public int getStudentId() { |
|
||||
return studentId; |
|
||||
} |
|
||||
|
|
||||
public String getName() { |
|
||||
return name; |
|
||||
} |
|
||||
|
|
||||
public double getScore() { |
|
||||
return score; |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue