private String name;
private double line;
public School(){};
public School(String name,double line) {
super();
this.name=name;
this.line = line;
}
public double getLine() {
return line;
}
public void setLine(double line) {
this.line = line;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class Student {
private String id;
private String name;
private double total;
private double sports;
public Student(){
}
public Student(String id, String name, double total, double sports) {
super();
this.id = id;
this.name = name;
this.total = total;
this.sports = sports;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getTotal() {
return total;
}
public void setTotal(double total) {
this.total = total;
}
public double getSports() {
return sports;
}
public void setSports(double sports) {
this.sports = sports;
}
}
public class Pass {
public void status(School s,Student stu){
if(stu.getTotal()>=s.getLine()||(stu.getSports()>=96||stu.getTotal()>=300)){
System.out.println("學號為:"+stu.getId()+" "+"姓名為:"+stu.getName()+"的同學被"+s.getName()+"錄取,該學校的錄取分數線為:"+s.getLine());
}else{
System.out.println("學號為:"+stu.getId()+" "+"姓名為:"+stu.getName()+"的同學沒有被"+s.getName()+"錄取,該學校的錄取分數線為:"+s.getLine());
}
}
public static void main(String[] args){
School school1=new School("清華大學",680);
School school2=new School("北京大學",660);
Student stu1=new Student("2012121201","小紅",690,80);
Student stu2=new Student("2012121201","小明",650,80);
Student stu3=new Student("2012121201","張三",670,80);
Student stu4=new Student("2012121201","李四",640,80);
Pass p=new Pass();
p.status(school1, stu1);
p.status(school1, stu2);
p.status(school2, stu3);
p.status(school2, stu4);
}
}
運行結果為:
學號為:2012121201 姓名為:小紅的同學被清華大學錄取,該學校的錄取分數線為:680.0
學號為:2012121201 姓名為:小明的同學被清華大學錄取,該學校的錄取分數線為:680.0
學號為:2012121201 姓名為:張三的同學被北京大學錄取,該學校的錄取分數線為:660.0
學號為:2012121201 姓名為:李四的同學被北京大學錄取,該學校的錄取分數線為:660.0