91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

資源中包含兩個實驗的代碼:①泛型棧模擬泛型隊列;②醫院簡易掛號管理系統

資源截圖

代碼片段和文件信息

package?javaLab1;
import?java.util.Stack;
import?java.util.NoSuchElementException;

/**
?*?
?*?@author?CS1502?
?*?????????U201414596?
?*?????????盧振興
?*?@param?
?*/

/*用兩個棧來模擬隊列,
?*入棧繼承Stack類的棧
?*出棧另定義一個泛型Stack*/
public?class?Queue?extends?Stack?{
private?static?final?long?serialVersionUID?=?1L;?
static?final?int?dump?=?10;????????//設置元素棧的大小
private?Stack?myStack;??????????//聲明泛型棧,該棧作為出口棧
public?Queue(?){?
myStack?=?new?Stack();? ???//初始化棧
};

//向隊列中插入元素,并在插入失敗的情況下拋出異常
public?boolean?add(E?e)?throws?IllegalStateException?ClassCastException?
NullPointerExceptionIllegalArgumentException
{
//如果入棧滿了,且出棧不為空,則報錯
if(super.size()?==?dump?&&?myStack.size()?!=0)?
{
throw?new?IllegalStateException();
}

if(super.size()? {//如果入棧的大小小于設置的棧的大小,那么直接入棧即可
super.push(e);
return?true;
}else
{//入棧已經滿了,則將入棧中的值全部倒入出棧
E?temp;
int?i?=?super.size();
while(i>0)
{
i--;
????????????????temp?=?(E)?super.get(i);
myStack.push(temp);
}
super.clear();
super.push(e);
}
return?true;
????}

//向隊列插入元素,在插入失敗的情況下返回false
public?boolean?offer(E?e)?throws?ClassCastException?NullPointerException?
IllegalArgumentException{?
if(super.size()?==?dump?&&?myStack.size()?!=0)
{
return?false;
}

if(super.size()? {
super.push(e);
return?true;
}else
{
E?temp;
int?i?=?super.size();
while(i>0)
{
i--;
????????????????temp?=?(E)?super.get(i);
myStack.push(temp);
}
super.clear();
super.push(e);
}
return?true;
}

//取出隊列的頭元素,并將其移出隊列
public??E?remove(?)?throws?NoSuchElementException?
{
if(!super.empty()?||?!myStack.empty())
{
if(!myStack.empty())
{
return?myStack.pop();
}else
{

E?temp;
int?i?=?super.size();
while(i>0)
{
i--;
????????????????temp?=?(E)?super.get(i);
myStack.push(temp);
}
super.clear();
return?myStack.pop();
}
}else
{
throw?new?NoSuchElementException();
}
}

//基本同remove只是在隊列為空時返回null
????public??E?poll(?)?{
if(!super.empty()?||?!myStack.empty())
{
if(myStack.size()!=0)
{
return?myStack.pop();

}else
{
E?temp;
int?i?=?super.size();
while(i>0)
{
i--;
????????????????temp?=?(E)?super.get(i);
myStack.push(temp);
}
super.clear();
return?myStack.pop();
}

}else{
return?null;
}
?????}
????
????//取出頭部
public??E?peek?(?)?{
???? if(!super.empty()?||?!myStack.empty())
{
if(!myStack.empty())
{
? return?myStack.peek();
}else
{
E?temp;
int?i?=?super.size();
while(i>0)
{
i--;
????????????????????temp?=?(E)?super.get(i);
myStack.push(temp);
}
super.clear();
? return?myStack.peek();
}
}else{
return?null;
}
????}

????public??E?element(?)?throws?NoSuchElementEx

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\
?????文件???????????0??2018-05-12?17:18??JAVA實驗\.metadata\.lock
?????文件????????8262??2018-05-15?15:37??JAVA實驗\.metadata\.log
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.mylyn\
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.mylyn\.taskListIndex\
?????文件??????????71??2018-05-12?17:18??JAVA實驗\.metadata\.mylyn\.taskListIndex\segments_1
?????文件???????????0??2018-05-12?17:18??JAVA實驗\.metadata\.mylyn\.taskListIndex\write.lock
?????文件?????????235??2018-05-15?15:59??JAVA實驗\.metadata\.mylyn\.tasks.xml.zip
?????目錄???????????0??2019-01-11?10:35??JAVA實驗\.metadata\.mylyn\contexts\
?????文件?????????561??2018-05-12?17:20??JAVA實驗\.metadata\.mylyn\repositories.xml.zip
?????文件?????????235??2018-05-15?16:03??JAVA實驗\.metadata\.mylyn\tasks.xml.zip
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\
?????目錄???????????0??2019-01-11?10:35??JAVA實驗\.metadata\.plugins\org.eclipse.buildship.core\
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.history\
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.history\9c\
?????文件????????4445??2018-05-15?15:23??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.history\9c\d004ae56165800181547d8265278da89
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.history\e1\
?????文件????????1356??2018-05-06?14:23??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.history\e1\90976d4e165800181547d8265278da89
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\javaLab1\
?????文件??????????81??2018-05-12?17:19??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\javaLab1\.location
?????文件?????????936??2018-05-13?14:50??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\javaLab1\.markers
?????文件??????????32??2018-05-15?15:56??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\javaLab1\.markers.snap
?????文件??????????32??2018-05-15?15:56??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\javaLab1\.syncinfo.snap
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\javaLab1\org.eclipse.jdt.core\
?????文件??????163132??2018-05-13?07:06??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\javaLab1\org.eclipse.jdt.core\state.dat
?????目錄???????????0??2019-01-11?10:32??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\lab2Patient\
?????文件??????????84??2018-05-15?15:37??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\lab2Patient\.location
?????文件????????4463??2018-05-15?15:56??JAVA實驗\.metadata\.plugins\org.eclipse.core.resources\.projects\lab2Patient\.markers.snap
............此處省略201個文件信息

評論

共有 條評論