/*定义并测试一个Student类
 *包括属性,学号,姓名,以及三门成绩,数学,英语,计算机
 *算总分,平均分,最高分,最低分
 */public class Student
{
private String no;
private String name;
private int math = 0;
private int eng = 0;
private int comp = 0;

//构造函数
Student(String no, String name)
{
this.no = no;
this.name = name;
}


Student(String no, String name, int math, int eng, int comp)
{
this(no, name);

this.math = math;
this.eng = eng;
this.comp = comp;
}

//取值
public String getNo()
{
return no;
}
public String getName()
{
return name;
}
public int getMath()
{
return math;
}
public int getEng()
{
return eng;
}
public int getComp()
{
return comp;
}

//附值
public void setName(String name)
{
this.name = name;
}
public void setMath(int math)
{
this.math = math;
}
public void setEng(int eng)
{
this.eng = eng;
}
public void setComp(int comp)
{
this.comp = comp;
}

//算总分
public int sum()
{
return(math + eng + comp);
}
//平均分
public int arg()
{
return(sum() /3);
}
//最高分
public int max()
{
int tmp = Math.max(math, eng);

if(tmp < comp)
{
tmp = comp;
}

return tmp;
}
//最低分
public int min()
{
int tmp = Math.min(math, eng);

if(tmp > comp)
{
tmp = comp;
}

return tmp;
}

public static void main(String argv[])
{
Student s = new Student("9772039", "Mechile");
s.setMath(90);
s.setEng(82);
s.setComp(89);

System.out.println("Student "+ s.getName() +" sum:" + s.sum());
System.out.println("Student "+ s.getName() +" arg:" + s.arg());
System.out.println("Student "+ s.getName() +" max:" + s.max());
System.out.println("Student "+ s.getName() +" min:" + s.min());
}
}