java类测试代码 java测试项目( 三 )


if(arr[i]!=nullarr[j]!=null){
if(arr[i].getC_sharp()arr[j].getC_sharp()){
Student t=arr[i];
arr[i]=arr[j];
arr[j]=t;
}
}
}
}
}else if(num==3){
for(int i=0;iarr.length;i++){
for(int j=i+1;jarr.length;j++){
if(arr[i]!=nullarr[j]!=null){
if(arr[i].getHtml()arr[j].getHtml()){
Student t=arr[i];
arr[i]=arr[j];
arr[j]=t;
}
}
}
}
}else if(num==4){
for(int i=0;iarr.length;i++){
for(int j=i+1;jarr.length;j++){
if(arr[i]!=nullarr[j]!=null){
if(arr[i].getSql()arr[j].getSql()){
Student t=arr[i];
arr[i]=arr[j];
arr[j]=t;
}
}
}
}
}
this.print(arr);
}
public void sumSort(Student[] arr){//总分排序方法
for(int i=0;iarr.length;i++){
for(int j=i+1;jarr.length;j++){
if(arr[i]!=nullarr[j]!=null){
if(arr[i].getSum()arr[j].getSum()){
Student t=arr[i];
arr[i]=arr[j];
arr[j]=t;
}
}
}
}
this.print(arr);
}
}
public class Student {//学生类
private int num;
private String name;
private int age;
private int java;
private int c_sharp;
private int html;
private int sql;
private int sum;
private double avg;
public int getNum(){
return num;
}
public void setNum(int num){
this.num=num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getJava() {
return java;
}
public void setJava(int java) {
this.java = java;
}
【java类测试代码 java测试项目】 public int getC_sharp() {
return c_sharp;
}
public void setC_sharp(int c_sharp) {
this.c_sharp = c_sharp;
}
public int getHtml() {
return html;
}
public void setHtml(int html) {
this.html = html;
}
public int getSql() {
return sql;
}
public void setSql(int sql) {
this.sql = sql;
}
public int getSum() {
return sum;
}
public void setSum() {
this.sum =this.java+this.c_sharp+this.html+this.sql;
}
public double getAvg() {
return avg;
}
public void setAvg() {
this.avg = this.sum/4;
}
public String toString(){
String msg="\t"+this.num+"\t"+this.name+"\t"+this.age+"\t"+this.java+"\t"+this.c_sharp+"\t"+this.html+"\t"+this.sql+"\t"+this.sum+"\t"+this.avg+"\t";
return msg;
}
}
import java.util.*;
public class Main {//主
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("---请定义学生的人数---");
Student[] stuArr=new Student[in.nextInt()];
Admin adminStu=new Admin();
while(true){
System.out.println("---选择你要执行的功能---");
System.out.println("0:添加一个学生");
System.out.println("1:查找一个学生");
System.out.println("2:根据编号更新信息");
System.out.println("3:根据编号删除学生");
System.out.println("4:根据编号输入成绩");
System.out.println("5:根据某门学科排序");
System.out.println("6:根据总分进行排序");
System.out.println("7:退出系统");
//int number =in.nextInt();//判断
String opt=in.next();
if(opt.equals("0")){
System.out.println("---执行添加方法---");
System.out.println("请输入学生的姓名:");
String name=in.next();
System.out.println("请输入学生的年龄:");

推荐阅读