sortedtestinfo.java

来自「一个较好的java开发实例」· Java 代码 · 共 89 行

JAVA
89
字号
/* * SortedTestInfo.java * * Created on 2004年1月19日, 下午4:30 */package romulus.Manager;import java.util.*;/** * * @author  Administrator * @version  */public class SortedTestInfo implements Comparable {    protected String name;        protected String Test;        protected double Score;        protected String Info;        /** Creates new SortedTestInfo */    public SortedTestInfo(String name, String Test, double Score, String Info) {        this.name = name;        this.Test = Test;        this.Score = Score;        this.Info = Info;    }        protected String getName(){        return this.name;    }        protected String getTest(){        return this.Test;    }        protected double getScore(){        return this.Score;    }        protected String getInfo(){        return this.Info;    }        protected String[] toArray(){        String[] ret = new String[4];        ret[0] = this.name;        ret[1] = this.Test;        ret[2] = this.Score+"";        ret[3] = this.Info;        return ret;    }        public int compareTo(java.lang.Object obj) {        int ret = 0;        if(! (obj instanceof SortedTestInfo)){            throw new java.lang.ClassCastException();        }        else{            SortedTestInfo test2 = (SortedTestInfo)obj;            if((ret = this.name.compareTo(test2.getName())) == 0){                if((ret = this.Test.compareTo(test2.getTest())) ==0){                    if(this.getScore()-test2.getScore() > 0.001){                        return 1;                    }                    else if(test2.getScore()-this.getScore() > 0.001){                        return -1;                    }                    else{                        return 0;                    }                }                else{                    return ret;                }            }            else{                return ret;            }        }    }        }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?