回 帖 发 新 帖 刷新版面

主题:各位高人,看看,帮我改改啊

1.
public class SepList implements List{
     final int defaultSize=10;
      
      int maxSize;
      int size;
      Object[] listArray;
       
    public int SeqList(){
           initiate(defaultSize);
       }
       
    public SeqList(int size){
          initiate(size);
      } 
      
      private initiate(int sz){
      maxSize=sz;
      size=0;
      listArray=new Object[sz];
      }
      
      public void insert(int i,Object obj) throws Exception{
      if(size=maxSize){
          throw new Exception("顺序表已满无法插入!");
      }
      if(i<0|i>size){ 
     throw new Exception("参数错误");
     }
      
     for(int j=size;j>i;j--)
     listArray[j]=listArray[j-1];
       
      listArray[i]=obj;
      size++;
    }
    public Object delete(int i) throws Exception{
        if(size==0){
            throw new Exception("顺序表已空无法删除!");
        }
        if(i<0|i>size-1){
            throw new Exception("参数错误!");
        }
        Object it=listArray[i];
        for(int j=i;j<size-1;j++)
        listArray[j]=listArray[j+1];
        
        size--;
        return it;
    }
    
    public Object getData(int i) throws Exception{
    if(i<0|i>=size){
       throw new Exception("参数错误!");
}
return listArray[i];
}
     public int size(){
return size;
}
  
public boolean isEmpty(){
return size=0;
}

public int MoreDataDelete(SeqList L,Object x) throws Exception{
int i,j;
int tag=0;
 for(i=0;i>L.size;i++){
     if(x.equals(L.getData(i))){
         L.delete(i);
         i--;
         tag=1;
     }
}
return tag;
}
}
 2.
public class SeqListTest{
    public static void main(String args[]){
        SeqLIst seqList=new SeqList(100);
        int n=10;
        try{
            for(int i=0;i<n;i++){
                seqList.insert(i,new Integer(i+1));
            }
            seqList.delete(4);
            for(int i=0;i<seqList.size;i++){
                System.out.print(seqList.getData(i)+"");
                }
                }
                catch(Exception e){
                    System.out.println(e.getMessage());
                    }
                    }
                    }        
3.
 public interface List{
public void insert() throws Exception;
 
public Object delete() throws Exception;

public Object getData() throws Exception;

public int size();

public boolean isEmpty();

这三个类我怎么弄不好啊,先正心急火燎地请高人的细心指点.多多帮忙啊[em18][em18][size=2][/size][size=6][/size]

回复列表 (共1个回复)

沙发

不说清到底要做什么,怎么帮你啊??
晕!!!!!!!!!!!!!!!!!!

我来回复

您尚未登录,请登录后再回复。点此登录或注册