package com.itheima;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
public class Test1 {
/**
* @param args
*/
public static void main(String[] args) {
Student[] stu=new Student[5];
}
public void StudentInput(){
}
}
/*
*
* 创建学生类
*/
class Student implements Comparable {
String name;//学生姓名
double chinese;//语文成绩
double math;//数学成绩
double english;//英语成绩
double sum;//总分
public Student(){
}
public Student(String name,double chinese,double math,double english,double sum){
this.name=name;
this.chinese=chinese;
this.math=math;
this.english=english;
this.sum=sum;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getChinese() {
return chinese;
}
public void setChinese(double chinese) {
this.chinese = chinese;
}
public double getMath() {
return math;
}
public void setMath(double math) {
this.math = math;
}
public double getEnglish() {
return english;
}
public void setEnglish(double english) {
this.english = english;
}
public double getSum() {
return sum;
}
public void setSum(double sum) {
this.sum = sum;
}
@Override
public int compareTo(Object o) {
Student s = (Student) o;
if (this.sum == s.sum) return this.name.compareTo(s.name);
if (this.sum >s.sum)
return -1;
else if (this.sum == s.sum)
return 0;
else return 1;
}
}
|
|