一个参数表示课程名称,第三个参数表示上课地点。
测试要求如下:
10创建包括所有特征的 2 个学生对象;
②输出这2个学生的总分和平均分;。
③第一个学生在2017年9月29日,在3223学习Java课程;第二个学生在2017年9月29日,在1402学习数据结构。
代码如下:
package Test;
class tudent{
private int StudyNmber;
private String name;
private int jScore;
private int sScore;
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public int getstudyNumber() {
return StudyNmber;
}
public void setstudyNumber(int number)
{
this.StudyNmber=number;
}
public int getjScore() {
return jScore;
}
public void setjScore(int score) {
this.jScore=score;
}
public int getsScore() {
return sScore;
}
public void setsScore(int score) {
this.sScore=score;
}
public tudent(int number,String name)
{
this.name=name;
this.StudyNmber=number;
}
public tudent(int number,String name,int jScore,int sScore)
{
this.name=name;
this.StudyNmber=number;
this.jScore=jScore;
this.sScore=sScore;
}
void caculate(String name,int jScore,int sScore) {
int avg=(jScore+sScore)/2;
int sum=jScore+sScore;
System.out.println(name+"总分为:"+sum+"平均分为:"+avg);
}
void showInfo() {
System.out.println("学号:"+getstudyNumber());
System.out.println("姓名:"+getName());
System.out.println("java成绩:"+getjScore());
System.out.println("数据结构成绩:"+getsScore());
}
void way(String time,String name,int where) {
System.out.println("在"+time+"学习"+name+"在"+where+"教室");
}
}
public class we {
public static void main(String[] args) {
// TODO Auto-generated method stub
tudent s1=new tudent(20001,"张三",60,80);
tudent s2=new tudent(20002,"赵四",90,60);
s1.way("2017年9月29日","java课程",3223);
s2.way("2013年9月29日", "数据结构",1402);
s1.caculate("张三",70,80);
s2.caculate("赵四", 90, 70);
}
}