Java學(xué)習(xí)期末項(xiàng)目詞典項(xiàng)目完整源碼1_第1頁(yè)
Java學(xué)習(xí)期末項(xiàng)目詞典項(xiàng)目完整源碼1_第2頁(yè)
Java學(xué)習(xí)期末項(xiàng)目詞典項(xiàng)目完整源碼1_第3頁(yè)
Java學(xué)習(xí)期末項(xiàng)目詞典項(xiàng)目完整源碼1_第4頁(yè)
Java學(xué)習(xí)期末項(xiàng)目詞典項(xiàng)目完整源碼1_第5頁(yè)
已閱讀5頁(yè),還剩35頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

第頁(yè)Dictionary項(xiàng)目源文件項(xiàng)目名稱英漢詞典二、主要構(gòu)成運(yùn)行效果1、三、項(xiàng)目介紹本項(xiàng)目使用文件存儲(chǔ)數(shù)據(jù)Dictionary類,包含對(duì)單詞的各種操作,如添加單詞,查詢單詞,刪除單詞Swing類,窗體界面類運(yùn)行效果圖如下Tools類,文件儲(chǔ)存工具類Word單詞屬性類UI,此UI為控制臺(tái)版本詞典,如不需窗體可以使用此類,運(yùn)行效果Dictionary類源代碼packageDictionary;*引用請(qǐng)注明原作者-愛(ài)露YSimportjava.util.*;publicclassDictionary{List<Word>list=newArrayList<Word>();//建立動(dòng)態(tài)鏈表 publicList<Word>getList(){ returnlist; publicvoidsetList(List<Word>list){ this.list=list; publicDictionary(){ super(); publicDictionary(Wordword){ publicWordaddWord(Wordword){//1、增加單詞 list.add(word);//輸出新增加的單詞 returnword; publicWordsearchWord(Stringstr){//2、查找單詞 // if(input_ce!=null)不需要判空 for(intj=0;j<list.size();j++) if((str.equals(((Word)list.get(j)).getcWord()))||((Word)list.get(j)).geteWord().equalsIgnoreCase(str)) return(Word)list.get(j); returnnull; publicStringsysoAllWrod(){//3、輸出全部單詞 List<Word>list=getList(); for(Wordword:list) returnword.toString(); returnnull; publicbooleandeleWord(StringDeleword){//4、刪除單詞 // if(input_ce!=null)不需要判空 {for(intj=0;j<list.size();j++) if((Deleword.equals(((Word)list.get(j)).getcWord()))||((Word)list.get(j)).geteWord().equalsIgnoreCase(Deleword)) list.remove(list.get(j)); returntrue; returnfalse; publicvoidclearWord(){//5、清空單詞 list.clear(); publicvoidchangeWord(inti,Stringcword,Stringeword){//6、修改單詞 this.list.get(i).setcWord(cword); this.list.get(i).seteWord(eword); publicvoidchioceWord(inti,Wordword) ((Word)list).setcWord(word.getcWord()); ((Word)list).seteWord(word.geteWord());Swing類源代碼packageDictionary;*引用請(qǐng)注明原作者-愛(ài)露YSimportjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.KeyEvent;importjava.awt.event.KeyListener;importjava.io.IOException;importjavax.swing.*;publicclassSwing{ Dictionarydictionary=newDictionary(); Toolstools=newTools(); privatestaticJFramejf; privatestaticJFramejf_creat_add; privatestaticJFramejf_creat_dele; privatestaticJFramejf_creat_clear; privatestaticFontfont; privatestaticFontfont_2; privatestaticJTextFieldtxtArea_1; privatestaticJTextAreatxtArea_2; privatestaticJTextFieldtextFieldCword; privatestaticJTextFieldtextFieldEword; privatestaticJTextFieldtextFieldDele; privatestaticLabellabel_2; privatestaticJButtonbutton_1; privatestaticJButtonbutton_2; privatestaticJButtonbutton_3; privatestaticJButtonbutton_4; privatestaticJButtonbutton_5; privatestaticJButtonbutton_6; privatestaticJButtonbutton_7; privatestaticJButtonbutton_8; privatestaticJButtonbutton_9; privatestaticJButtonbutton_10; privatestaticJButtonbutton_clear_ok; privatestaticJButtonbutton_clear_no; publicvoidCreateJFrame(Stringtitle)throwsIOException{ tools.ReadertoFile(dictionary.getList(),"d:/Java詞典文件/文件/dic.txt"); jf=newJFrame(title); //Containercontainer=jf.getContentPane();//獲取一個(gè)容器 ImageIconic=newImageIcon("D:\\Java詞典文件\\圖片\\詞典背景.png"); JLabellabel=newJLabel(ic); label.setHorizontalAlignment(SwingConstants.CENTER);//居中 //label.setIcon(ic); //把標(biāo)簽的大小位置設(shè)置為圖片剛好填充整個(gè)面 label.setBounds(0,0,ic.getIconWidth(),ic.getIconHeight()); //添加圖片到frame的第二層 jf.getLayeredPane().add(label,newInteger(Integer.MIN_VALUE)); //獲取frame的最上層面板為了設(shè)置其背景顏色(JPanel有設(shè)置透明的方法) JPaneljp=(JPanel)jf.getContentPane(); jp.setOpaque(false);//設(shè)置透明 //彈窗 //JOptionPane.showMessageDialog(null,"<html><B><fontsize='15'>歡迎使用英漢詞典!</font></B></html>"); //container.setBackground(Color.white);//背景顏色 //jf.setLayout(newBorderLayout());//邊界布局 BorderLayoutbl_1=newBorderLayout();//邊界布局 FlowLayoutfl_1=newFlowLayout();//流布局 FlowLayoutfl_2=newFlowLayout(); FlowLayoutfl_3=newFlowLayout(1,20,10); JPanelcontent_1=newJPanel(bl_1); JPanelcontent_2=newJPanel(fl_1); JPanelcontent_3=newJPanel(fl_2); JPanelcontent_4=newJPanel(fl_3); jf.setContentPane(content_1); content_1.setOpaque(false); content_2.setOpaque(false); content_3.setOpaque(false); content_4.setOpaque(false); font=newFont("宋體",Font.BOLD,15); font_2=newFont("宋體",Font.BOLD,25); txtArea_1=newJTextField("歡迎使用英漢詞典!",20); txtArea_2=newJTextArea(11,32); label_2=newLabel("請(qǐng)輸入:"); button_1=newJButton("查詢"); button_2=newJButton("添加單詞"); button_3=newJButton("刪除單詞"); button_4=newJButton("全部單詞"); button_5=newJButton("清空單詞"); button_6=newJButton("退出"); label_2.setFont(font); txtArea_1.setOpaque(false); txtArea_2.setOpaque(false);//結(jié)果文本框透明顯示 JScrollPanejspane=newJScrollPane(txtArea_2);//帶滾動(dòng)條的面板 jspane.setOpaque(false);//透明 jspane.getViewport().setOpaque(false);//透明 //txtArea_1.setLineWrap(false);//自動(dòng)換行 //txtArea_2.setLineWrap(true); txtArea_2.setEditable(false);//不允許編輯 txtArea_1.setFont(font_2); txtArea_2.setFont(font_2); txtArea_2.setForeground(Color.white);//文本域字體顏色 content_1.add(BorderLayout.NORTH,content_2); content_1.add(BorderLayout.CENTER,content_3); content_1.add(BorderLayout.SOUTH,content_4); content_2.add(label_2); content_2.add(txtArea_1); content_2.add(button_1); content_3.add(jspane); content_4.add(button_2); content_4.add(button_3); content_4.add(button_4); content_4.add(button_5); content_4.add(button_6); //txtArea.setBackground(Color.white); /*jf.setLayout(newFlowLayout(0,20,13)); container.add(label_2); container.add(txtArea_1); container.add(button_1); container.add(jspane); container.add(button_2); container.add(button_3); container.add(button_4); container.add(button_5); container.add(button_6);*/ jf.setResizable(false);//不允許改變窗口大小 jf.setSize(578,465); jf.setVisible(true);//使窗體可見(jiàn) jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);//關(guān)閉方式 //按鈕1查詢 publicvoidActionButton_1(){ button_1.addActionListener(newbutton_1Action()); classbutton_1ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ dictionary.searchWord(txtArea_1.getText()); if(dictionary.searchWord(txtArea_1.getText())!=null){ Stringserchstring=dictionary.searchWord(txtArea_1.getText()).getcWord()+"--"+dictionary.searchWord(txtArea_1.getText()).geteWord(); txtArea_2.setText(serchstring); elsetxtArea_2.setText("沒(méi)有此單詞!"); //dictionary.searchWord(txtArea_2.getText()).getcWord()+dictionary.searchWord(txtArea_2.getText()).geteWord() publicvoidActionTxtArea_1_Mouse(){ //單擊文本框 txtArea_1.addMouseListener(newjava.awt.event.MouseAdapter(){ publicvoidmouseClicked(java.awt.event.MouseEvente){ txtArea_1.setText(""); //監(jiān)聽(tīng)文本框按鍵操作 txtArea_1.addKeyListener(newKeyListener(){ publicvoidkeyTyped(KeyEvente){ //TODOAuto-generatedmethodstub if(e.getSource()==txtArea_1) dictionary.searchWord(txtArea_1.getText()); if(dictionary.searchWord(txtArea_1.getText())!=null){ Stringserchstring=dictionary.searchWord(txtArea_1.getText()).getcWord()+"--"+dictionary.searchWord(txtArea_1.getText()).geteWord(); txtArea_2.setText(serchstring); elsetxtArea_2.setText("沒(méi)有此單詞!"); publicvoidkeyReleased(KeyEvente){ //TODOAuto-generatedmethodstub publicvoidkeyPressed(KeyEvente){ //TODOAuto-generatedmethodstub //按鈕2新建彈窗增加單詞 publicvoidActionButton_2(){ button_2.addActionListener(newbutton_2Action()); classbutton_2ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ ActionButton_6_Quit(); CreatJFrame_Add(); ActionButton_7(); ActionButton_8(); //刪除單詞 publicvoidActionButton_3(){ button_3.addActionListener(newbutton_3Action()); classbutton_3ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ CreatJFrame_Dele(); ActionButton_9(); ActionButton_10(); //顯示全部單詞 publicvoidActionButton_4(){ button_4.addActionListener(newbutton_4Action()); classbutton_4ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ Stringstr=newString(); StringBuffersBuffer=newStringBuffer(); for(intj=0;j<dictionary.list.size();j++){ str=dictionary.getList().get(j).toString();//.getcWord()+"--"+dictionary.getList().get(j).geteWord(); sBuffer.append(str+"\n"); if(sBuffer.toString().length()!=0){ txtArea_2.setText(sBuffer.toString()); elsetxtArea_2.setText("詞典內(nèi)沒(méi)有單詞!"); //清空單詞 publicvoidActionButton_5(){ button_5.addActionListener(newbutton_5Action()); classbutton_5ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ CreatJFrame_Clear(); ActionButton_clear_no(); ActionButton_clear_ok(); //添加單詞確認(rèn)按鈕 publicvoidActionButton_7(){ button_7.addActionListener(newbutton_7Action()); classbutton_7ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ if(textFieldCword.getText().length()==0||textFieldEword.getText().length()==0){ JOptionPane.showMessageDialog(null,"<html><B><fontsize='7'>請(qǐng)輸入完整的單詞!</font></B></html>"); else{ Wordword=newWord(textFieldCword.getText(),textFieldEword.getText()); dictionary.addWord(word); tools.SaveToFile("d:/Java詞典文件/文件/dic.txt",dictionary.getList()); JOptionPane.showMessageDialog(null,"<html><B><fontsize='12'>添加成功!</font></B></html>"); // jf_creat_add.dispose(); //添加單詞取消按鈕 publicvoidActionButton_8(){ button_8.addActionListener(newbutton_8Action()); classbutton_8ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ jf_creat_add.dispose(); //刪除單詞確認(rèn)按鈕 publicvoidActionButton_9(){ button_9.addActionListener(newbutton_9Action()); classbutton_9ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ if(textFieldDele.getText().length()!=0&&dictionary.deleWord(textFieldDele.getText())==true){ dictionary.deleWord(textFieldDele.getText()); JOptionPane.showMessageDialog(null,"<html><B><fontsize='12'>刪除成功!</font></B></html>"); tools.SaveToFile("d:/Java詞典文件/文件/dic.txt",dictionary.getList()); jf_creat_dele.dispose(); elseif(textFieldDele.getText().length()==0){ JOptionPane.showMessageDialog(null,"<html><B><fontsize='9'>請(qǐng)輸入需要?jiǎng)h除的單詞!</font></B></html>"); elseif(textFieldDele.getText().length()!=0&&dictionary.deleWord(textFieldDele.getText())==false) JOptionPane.showMessageDialog(null,"<html><B><fontsize='11'>單詞不存在!</font></B></html>"); //刪除單詞取消按鈕 publicvoidActionButton_10(){ button_10.addActionListener(newbutton_10Action()); classbutton_10ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ jf_creat_dele.dispose(); //清空單詞取消按鈕 publicvoidActionButton_clear_no(){ button_clear_no.addActionListener(newbutton_clear_noAction()); classbutton_clear_noActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ jf_creat_clear.dispose(); //清空單詞確認(rèn)按鈕 publicvoidActionButton_clear_ok(){ button_clear_ok.addActionListener(newButton_clear_okAction()); classButton_clear_okActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ dictionary.clearWord(); tools.SaveToFile("d:/Java詞典文件/文件/dic.txt",dictionary.getList()); JOptionPane.showMessageDialog(null,"<html><B><fontsize='12'>刪除成功!</font></B></html>"); jf_creat_clear.dispose(); //退出 publicvoidActionButton_6_Quit(){ button_6.addActionListener(newbutton_6Action()); classbutton_6ActionimplementsActionListener{ publicvoidactionPerformed(ActionEventarg0){ jf.dispose(); //彈窗 publicvoidCreatJFrame_Add(){ jf_creat_add=newJFrame("添加單詞"); //Containercontainer_2=jf.getContentPane();//獲取一個(gè)容器 ImageIconic=newImageIcon("D:\\Java詞典文件\\圖片\\1.jpg"); JLabellabel=newJLabel(ic); label.setHorizontalAlignment(SwingConstants.CENTER);//居中 //label.setIcon(ic); //把標(biāo)簽的大小位置設(shè)置為圖片剛好填充整個(gè)面 label.setBounds(0,0,ic.getIconWidth(),ic.getIconHeight()); //添加圖片到frame的第二層 jf_creat_add.getLayeredPane().add(label,newInteger(Integer.MIN_VALUE)); //獲取frame的最上層面板為了設(shè)置其背景顏色(JPanel有設(shè)置透明的方法) JPaneljp=(JPanel)jf_creat_add.getContentPane(); jp.setOpaque(false);//設(shè)置透明 BorderLayoutbl_1=newBorderLayout();//邊界布局 BorderLayoutbl_2=newBorderLayout(); BorderLayoutbl_3=newBorderLayout(); FlowLayoutfl_1=newFlowLayout(1,10,30);//流布局 FlowLayoutfl_2=newFlowLayout(1,10,30); FlowLayoutfl_3=newFlowLayout(1,100,60); JPanelcontent=newJPanel(bl_1); JPanelcontent_1=newJPanel(bl_2); JPanelcontent_2=newJPanel(bl_3); JPanelcontent_3=newJPanel(fl_1); JPanelcontent_4=newJPanel(fl_2); JPanelcontent_5=newJPanel(fl_3); jf_creat_add.setContentPane(content); content.add(BorderLayout.CENTER,content_1); content_1.add(BorderLayout.CENTER,content_2); content_1.add(BorderLayout.NORTH,content_3); content_1.add(BorderLayout.CENTER,content_4); content_1.add(BorderLayout.SOUTH,content_5); //content_1.add(BorderLayout.CENTER,content_3); textFieldCword=newJTextField(20); textFieldEword=newJTextField(20); JLabellabel_cword=newJLabel("請(qǐng)輸入中文:"); JLabellabel_eword=newJLabel("請(qǐng)輸入英文:"); font=newFont("宋體",Font.BOLD,20); textFieldCword.setFont(font); textFieldEword.setFont(font); textFieldCword.setOpaque(false); textFieldEword.setOpaque(false); button_7=newJButton("確定"); button_8=newJButton("退出"); content_3.add(label_cword); content_3.add(textFieldCword); content_4.add(label_eword); content_4.add(textFieldEword); content_5.add(button_7); content_5.add(button_8); content.setOpaque(false); content_1.setOpaque(false); content_2.setOpaque(false); content_3.setOpaque(false); content_4.setOpaque(false); content_5.setOpaque(false); jf_creat_add.setResizable(false);//不允許改變窗口大小 jf_creat_add.setSize(454,333); jf_creat_add.setVisible(true);//使窗體可見(jiàn) //刪除 publicvoidCreatJFrame_Dele(){ jf_creat_dele=newJFrame("刪除單詞"); //Containercontainer_2=jf.getContentPane();//獲取一個(gè)容器 ImageIconic=newImageIcon("D:\\Java詞典文件\\圖片\\1.jpg"); JLabellabel=newJLabel(ic); label.setHorizontalAlignment(SwingConstants.CENTER);//居中 //label.setIcon(ic); //把標(biāo)簽的大小位置設(shè)置為圖片剛好填充整個(gè)面 label.setBounds(0,0,ic.getIconWidth(),ic.getIconHeight()); //添加圖片到frame的第二層 jf_creat_dele.getLayeredPane().add(label,newInteger(Integer.MIN_VALUE)); //獲取frame的最上層面板為了設(shè)置其背景顏色(JPanel有設(shè)置透明的方法) JPaneljp=(JPanel)jf_creat_dele.getContentPane(); jp.setOpaque(false);//設(shè)置透明 BorderLayoutbl_1=newBorderLayout();//邊界布局 BorderLayoutbl_2=newBorderLayout(); FlowLayoutfl_1=newFlowLayout(1,10,10);//流布局 FlowLayoutfl_2=newFlowLayout(1,2,30); FlowLayoutfl_3=newFlowLayout(1,100,30); JPanelcontent=newJPanel(bl_1); JPanelcontent_1=newJPanel(bl_2); JPanelcontent_3=newJPanel(fl_1); JPanelcontent_4=newJPanel(fl_2); JPanelcontent_5=newJPanel(fl_3); jf_creat_dele.setContentPane(content); content.add(BorderLayout.CENTER,content_1); content_1.add(BorderLayout.NORTH,content_3); content_1.add(BorderLayout.CENTER,content_4); content_1.add(BorderLayout.SOUTH,content_5); //content_1.add(BorderLayout.CENTER,content_3); textFieldDele=newJTextField(20); textFieldDele.setOpaque(false); JLabellabel_Dele=newJLabel("請(qǐng)輸入中文或英文:"); font=newFont("宋體",Font.BOLD,18); textFieldDele.setFont(font); button_9=newJButton("確定"); button_10=newJButton("取消"); //content_3.add(label_cword); //content_3.add(textFieldCword); content_4.add(label_Dele); content_4.add(textFieldDele); content_5.add(button_9); content_5.add(button_10); content.setOpaque(false); content_1.setOpaque(false); content_3.setOpaque(false); content_4.setOpaque(false); content_5.setOpaque(false); jf_creat_dele.setResizable(false);//不允許改變窗口大小 jf_creat_dele.setSize(400,250); jf_creat_dele.setVisible(true);//使窗體可見(jiàn) //清空單詞 publicvoidCreatJFrame_Clear(){ jf_creat_clear=newJFrame("清空單詞"); //Containercontainer_2=jf.getContentPane();//獲取一個(gè)容器 ImageIconic=newImageIcon("D:\\Java詞典文件\\圖片\\1.jpg"); JLabellabel=newJLabel(ic); label.setHorizontalAlignment(SwingConstants.CENTER);//居中 //label.setIcon(ic); //把標(biāo)簽的大小位置設(shè)置為圖片剛好填充整個(gè)面 label.setBounds(0,0,ic.getIconWidth(),ic.getIconHeight()); //添加圖片到frame的第二層 jf_creat_clear.getLayeredPane().add(label,newInteger(Integer.MIN_VALUE)); //獲取frame的最上層面板為了設(shè)置其背景顏色(JPanel有設(shè)置透明的方法) JPaneljp=(JPanel)jf_creat_clear.getContentPane(); jp.setOpaque(false);//設(shè)置透明 BorderLayoutbl_clear=newBorderLayout(); FlowLayoutfl_clear=newFlowLayout(1,30,10); FlowLayoutfl_clear_label=newFlowLayout(1,30,35); Labellabel_clear=newLabel("你是否要清空全部單詞?"); JPanelcontent_bl_clear=newJPanel(bl_clear); JPanelcontent_fl_clear=newJPanel(fl_clear); JPanelcontent_fl_clear_label=newJPanel(fl_clear_label); jf_creat_clear.setContentPane(content_bl_clear); font=newFont("宋體",Font.BOLD,15); label_clear.setFont(font); button_clear_ok=newJButton("確定"); button_clear_no=newJButton("取消"); content_bl_clear.add(BorderLayout.SOUTH,content_fl_clear); content_bl_clear.add(BorderLayout.CENTER,content_fl_clear_label); content_fl_clear_label.add(label_clear); content_fl_clear.add(button_clear_ok); content_fl_clear.add(button_clear_no); content_bl_clear.setOpaque(false); content_fl_clear.setOpaque(false); content_fl_clear_label.setOpaque(false); jf_creat_clear.setResizable(false);//不允許改變窗口大小 jf_creat_clear.setSize(250,150); jf_creat_clear.setVisible(true);//使窗體可見(jiàn)*引用請(qǐng)注明原作者-愛(ài)露YSMainDic類packageDictionary;*引用請(qǐng)注明原作者-愛(ài)露YSimportjava.io.IOException;publicclassMainDic{ publicstaticvoidmain(String[]args)throwsIOException{ /* UIui=newUI(); ui.uiMenu();*/ Swingswing=newSwing(); swing.CreateJFrame("英漢詞典version-2.0.0"); swing.ActionButton_1(); swing.ActionButton_2(); swing.ActionTxtArea_1_Mouse(); swing.ActionButton_3(); swing.ActionButton_6_Quit(); swing.ActionButton_4(); swing.ActionButton_5();Tools類packageDictionary;*引用請(qǐng)注明原作者-愛(ài)露YSimportjava.io.BufferedReader;importjava.io.*;importjava.io.FileReader;importjava.io.FileWriter;importjava.io.IOException;importjava.util.List;publicclassTools{ //保存文件 publicvoidSaveToFile(Stringfilename,List<Word>list){ try{ FileWriterwr=newFileWriter(filename); for(inti=0;i<list.size();i++) Wordword=list.get(i); wr.write(word.getcWord()+","+word.geteWord()+"\n"); wr.close(); }catch(IOExceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); //讀取文件方法 publicvoidReadertoFile(List<Word>list,StringFilename)throwsIOException{ Filefile=newFile(Filename); booleanP=file.exists();//判斷文件是否存在, if(P==false){ file.createNewFile(); FileReaderreader; BufferedReaderbufer; reader=newFileReader(Filename); bufer=newBufferedReader(reader); Stringstr; try{ while((str=bufer.readLine())!=null){ Wordword=newWord(); String[]liance=str.split(","); word.setcWord(liance[0]); word.seteWord(liance[1]); list.add(word); bufer.close(); reader.close(); }catch(IOExceptione){ //TODOAuto-generatedcatchblock e.printStackTrace();UI類packageDictionary;*控制窗口版本UIimportjava.io.IOException;importjava.util.Scanner;publicclassUI{publicvoiduiMenu()throwsIOException{ Dictionarydictionary=newDictionary(); Toolstools=newTools(); tools.ReadertoFile(dictionary.getList(),"d:/桌面文檔/文件練習(xí)/dic.txt"); System.out.println(""); System.out.println("歡迎使用單詞查詢系統(tǒng)"); System.out.println(""); do try{ do{ 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("-0退出系統(tǒng)"); System.out.println(""); System.out.println("Version1.1.0-"); System.out.println("請(qǐng)選擇你需要的功能:"); ScannerinputScanner=newScanner(System.in); inti=inputScanner.nextInt();switch(i){case1://查詢單詞 System.out.println("請(qǐng)輸入查找的單詞:"); Scannerinput=newScanner(System.in); Stringinput_ce=input.next(); if(dictionary.searchWord(input_ce)!=null){ System.out.println(dictionary.searchWord(input_ce));break;case2://增加單詞 Scannerinput_add=newScanner(System.in);//輸入 System.out.println("請(qǐng)輸入增加單詞的中文含義:"); Stringinput_C=input_add.next(); System.out.println("請(qǐng)輸入增加單詞的英文表示:"); Stringinput_E=input_add.next(); WordaddWord=newWord(input_C,input_E); dictionary.addWord(addWord); System.out.println("單詞增加成功!"); System.out.p

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論