class Student { int num; String name; double math,chinese,english; int paiming; public void setStudent(int s,String a,double b,double c,double d,int e) { num=s;name=a;math=b;chinese=c;english=d;paiming=e; } public boolean search(int s) { if(s==num) { return true; } else return false; } public String toString() { String str=""; str+="姓名:"+name+"n"; str+="数学:"+math+"n"; str+="语文:"+chinese+"n"; str+="外语:"+english+"n"; str+="排名:"+paiming+"n"; return str; } public void disp() { System.out.print(toString()); } public static void main(String[] args) { int num1=Integer.valueOf(args[0]).intValue(); Student s1=new Student(),s2=new Student(),s3=new Student(),s4=new Student(), s5=new Student(); s1.setStudent(20201001,"小明",100,100,100,1); s2.setStudent(20201002,"小王",90,90,90,2); s3.setStudent(20201003,"小张",80,80,80,3); s4.setStudent(20201004,"小红",70,70,70,4); s5.setStudent(20201005,"小绿",60,60,60,5); if(s1.search(num1)) { s1.disp(); } if(s2.search(num1)) { s2.disp(); } if(s3.search(num1)) { s3.disp(); } if(s4.search(num1)) { s4.disp(); } if(s5.search(num1)) { s5.disp(); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)