//接口 since
public interface since{
public void push(Object obj) throws Exception;
public Object pop() throws Exception;
public Object getTop() throws Exception;
public boolean notEmpty();
}
// 实现接口since里的方法
public class Seqsince implements since {
final int defaultSize=10;
int top;
Object[] since;
int maxsinceSize;
public Seqsince(){
initiate(defaultSize);
}
public Seqsince(int sz){
initiate(sz);
}
private void initiate(int sz){
maxsinceSize=sz;
top=0;
since=new Object[sz];
}
public void push(Object obj) throws Exception{
if(top==maxsinceSize){
throw new Exception("堆栈已满");
}
since[top]=obj;
top++;
}
public Object pop()throws Exception{
if(top==0){
throw new Exception("堆栈已空");
}
top--;
return since[top];
}
public Object getTop() throws Exception{
if(top==0){
throw new Exception("堆栈已空");
}
return since[top-1];
}public boolean notEmpty(){
return (top>0);
}
}
//接口 Queue
public interface Queue {
public void append(Object obj) throws Exception;
public Object delete() throws Exception;
public Object getFront() throws Exception;
public boolean notEmpty();
}
//实现接口Queue里的方法
public class SeqQueue implements Queue{
static final int defaultSize=10;
int front;
int rear;
int count;
int maxsize;
Object[] data;
public SeqQueue(){
initiate(defaultSize);
}
public SeqQueue(int sz){
initiate(sz);
}
private void initiate(int sz){
maxsize=sz;
front=rear=0;
count=0;
data=new Object[sz];
}
public void append(Object