该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
public class Score {
private float projectScore;
/**
* 实验分数
*/
private float experimentScore;
public float getProjectScore() {
return projectScore;
}
public void setProjectScore(float projectScore) {
this.projectScore = projectScore;
}
public float getExperimentScore() {
return experimentScore;
}
public void setExperimentScore(float experimentScore) {
this.experimentScore = experimentScore;
}
}
public class Student {
/**
* id
*/
private Long id;
/**
* 姓名
*/
private String name;
/**
* 分数
*/
private Score score;
/**
* 创建一个新的实例 Student.
*
* @param name
* @param score
*/
public Student(String name, Score score) {
this.name = name;
this.score = score;
}
/**
* 创建一个新的实例 Student.
*
* @param id
* @param name
* @param score
*/
public Student(Long id, String name, Score score) {
super();
this.id = id;
this.name = name;
this.score = score;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Score getScore() {
return score;
}
public void setScore(Score score) {
this.score = score;
}
}
public class Test {
public static void main(String[] args) {
Score score = new Score();
score.setProjectScore(98.9f);
score.setExperimentScore(100.0f);
Student student = new Student("xiaoming", score);
System.out.println("学生姓名:"+student.getName());
System.out.println("工程分数:"+student.getScore().getExperimentScore());
System.out.println("实验分数:"+student.getScore().getProjectScore());
}
}