




已閱讀5頁(yè),還剩11頁(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)介
課程設(shè)計(jì)(1)報(bào)告( 2009 / 2010 學(xué)年 第 二 學(xué)期)題目(1): 文本文件編輯程序 題目(2): 頁(yè)面調(diào)度算法OPT的模擬實(shí)現(xiàn) 專 業(yè) 計(jì)算機(jī)科學(xué)與技術(shù) 學(xué) 生 姓 名 陳炳陽(yáng) 班 級(jí) 學(xué) 號(hào) B07030523 指 導(dǎo) 教 師 張 琳 指 導(dǎo) 單 位 計(jì)算機(jī)學(xué)院 計(jì)算機(jī)科學(xué)與技術(shù)系 日 期 2010.05.242010.06.04指導(dǎo)教師成績(jī)?cè)u(píng)定表學(xué)生姓名陳炳陽(yáng)班級(jí)學(xué)號(hào)B07030531專業(yè)計(jì)算機(jī)科學(xué)與技術(shù)評(píng)分內(nèi)容評(píng)分標(biāo)準(zhǔn)優(yōu)秀良好中等差平時(shí)成績(jī)認(rèn)真對(duì)待課程設(shè)計(jì),遵守實(shí)驗(yàn)室規(guī)定,上機(jī)不遲到早退,不做和設(shè)計(jì)無(wú)關(guān)的事設(shè)計(jì)成果設(shè)計(jì)的科學(xué)、合理性功能豐富、符合題目要求 界面友好、外觀漂亮、大方程序功能執(zhí)行的正確性程序算法執(zhí)行的效能設(shè)計(jì)報(bào)告設(shè)計(jì)報(bào)告正確合理、反映系統(tǒng)設(shè)計(jì)流程文檔內(nèi)容詳實(shí)程度文檔格式規(guī)范、排版美觀驗(yàn)收答辯簡(jiǎn)練、準(zhǔn)確闡述設(shè)計(jì)內(nèi)容,能準(zhǔn)確有條理回答各種問(wèn)題,系統(tǒng)演示順利。評(píng)分等級(jí)指導(dǎo)教師簡(jiǎn)短評(píng)語(yǔ)指導(dǎo)教師簽名日期2010.06.11備注評(píng)分等級(jí)有五種:優(yōu)秀、良好、中等、及格、不及格題目一:文本文檔編輯器一、 課題內(nèi)容和要求采用JAVA SWING,設(shè)計(jì)可用于文本文件編輯的程序,要求能正確打開和保存文本文件,能進(jìn)行文本的修改等功能。二、需求分析本次試驗(yàn),,本人使用了MyEclipse程序,熟悉了許多頭文件的作用。三、概要設(shè)計(jì) 1、由于要有文本輸入和保存,因此要新建一個(gè)文本文檔private JFrame frame; private JTextArea textarea; private String filename; public void createEditor() JMenuBar menubar = new JMenuBar(); JMenu menufile = new JMenu(文件); JMenuItem menunew = new JMenuItem(新建); menunew.addActionListener(this); menufile.add(menunew);建立菜單,實(shí)現(xiàn)打開,輸入,保存,JMenuItem menunew = new JMenuItem(新建); menunew.addActionListener(this); menufile.add(menunew); JMenuItem menuopen = new JMenuItem(打開); menuopen.addActionListener(this); menufile.add(menuopen); JMenuItem menusave = new JMenuItem(保存); menusave.addActionListener(this); menufile.add(menusave);主函數(shù)public static void main(String args) JTextEditor te = new JTextEditor(); te.createEditor(); ;四、詳細(xì)設(shè)計(jì) 實(shí)驗(yàn)源代碼package com.demo;import java.awt.BorderLayout;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.io.PrintWriter;import javax.swing.JDialog;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JPanel;import javax.swing.JTextArea;public class JTextEditor extends WindowAdapter implements ActionListener private JFrame frame;/ 主窗體 private JTextArea textarea;/ 文本輸入?yún)^(qū)域 private String filename;/ 打開的文件名 public void createEditor() / 建立文件菜單 JMenuBar menubar = new JMenuBar(); JMenu menufile = new JMenu(文件); / 新建菜單 JMenuItem menunew = new JMenuItem(新建); menunew.addActionListener(this); menufile.add(menunew); / 打開菜單 JMenuItem menuopen = new JMenuItem(打開); menuopen.addActionListener(this); menufile.add(menuopen); / 保存菜單 JMenuItem menusave = new JMenuItem(保存); menusave.addActionListener(this); menufile.add(menusave); / 另存為菜單 JMenuItem menusave2 = new JMenuItem(另存為.); menusave2.addActionListener(this); menufile.add(menusave2); / 退出菜單 menufile.addSeparator(); JMenuItem menuexit = new JMenuItem(退出); menuexit.addActionListener(this); menufile.add(menuexit); menubar.add(menufile); / 建立幫助菜單 JMenu menuhelp = new JMenu(幫助); JMenuItem menuabout = new JMenuItem(關(guān)于); menuabout.addActionListener(this); menuhelp.add(menuabout); menubar.add(menuhelp); / 主窗口 frame = new JFrame(Java文本編輯器); frame.setJMenuBar(menubar); textarea = new JTextArea(); frame.add(Center, textarea); frame.addWindowListener(this);/ 注冊(cè)窗口關(guān)閉監(jiān)聽器 frame.setSize(600, 400); frame.setVisible(true); / 菜單選擇事件 public void actionPerformed(ActionEvent e) try if (e.getActionCommand() = 新建) textarea.setText(); else if (e.getActionCommand() = 打開) / 選擇文件 JFileChooser dlg = new JFileChooser(); int result = dlg.showOpenDialog(frame); if (result = JFileChooser.APPROVE_OPTION) File file = dlg.getSelectedFile(); filename = file.getAbsolutePath(); / 讀取文件 FileReader fr = new FileReader(filename); BufferedReader br = new BufferedReader(fr); String str = ; while (br.ready() int c = br.read(); str += (char) c; textarea.setText(str); br.close(); fr.close(); frame.setTitle(Java文本編輯器 - + filename); else if (e.getActionCommand() = 保存) / 寫入文件 File file = new File(filename); FileWriter fos = new FileWriter(file, true); BufferedWriter bos = new BufferedWriter(fos); PrintWriter pos = new PrintWriter(bos); / 寫入對(duì)象數(shù)據(jù) pos.print(textarea.getText(); / 關(guān)閉輸出流 bos.close(); pos.close(); fos.close(); else if (e.getActionCommand() = 另存為.) / 選擇文件 JFileChooser dlg = new JFileChooser(); int result = dlg.showOpenDialog(frame); if (result = JFileChooser.APPROVE_OPTION) File file = dlg.getSelectedFile(); / 寫入文件 FileWriter fos = new FileWriter(file, true); BufferedWriter bos = new BufferedWriter(fos); PrintWriter pos = new PrintWriter(bos); / 寫入對(duì)象數(shù)據(jù) pos.print(textarea.getText(); / 關(guān)閉輸出流 bos.close(); pos.close(); fos.close(); else if (e.getActionCommand() = 退出) System.exit(0); else if (e.getActionCommand() = 關(guān)于) / 顯示關(guān)于對(duì)話框 final JDialog dialog = new JDialog(frame, 關(guān)于, true); dialog.setSize(267, 117); dialog.setLayout(new GridLayout(2, 1); / 窗口關(guān)閉事件 dialog.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dialog.dispose(); ); / 顯示消息 JPanel topPanel = new JPanel(); JLabel label = new JLabel(Java文本編輯器); topPanel.add(label, BorderLayout.NORTH); dialog.add(topPanel); dialog.setVisible(true); catch (Exception ex) ex.printStackTrace(); / 關(guān)閉窗體事件 public void windowClosing(WindowEvent e) System.exit(0); / 主函數(shù) public static void main(String args) JTextEditor te = new JTextEditor(); te.createEditor(); 五、測(cè)試數(shù)據(jù)及其結(jié)果分析測(cè)試結(jié)果(如下圖所示):文本編輯器界面輸入存儲(chǔ)功能結(jié)果分析:能基本實(shí)現(xiàn)輸入保存功能,由于余下時(shí)間倉(cāng)促,未能調(diào)試實(shí)現(xiàn)字體,復(fù)制,粘貼等功能1、 算法分析: 首先新建一個(gè)文件菜單,在次基礎(chǔ)上繼續(xù)建新建,打開,保存,另存為,退出菜單.建立菜單選擇時(shí)間以便選擇文件,讀取文件.陸續(xù)建立寫入文件,寫入對(duì)象數(shù)據(jù),關(guān)閉輸出最后關(guān)閉對(duì)象窗體六、調(diào)試過(guò)程中的問(wèn)題FileReader fr = new FileReader(filename); BufferedReader br = new BufferedReader(fr); String str = ; while (br.ready() int c = br.read(); str += (char) c; textarea.setText(str); br.close(); fr.close(); frame.setTitle(Java文本編輯器 - + filename); else if (e.getActionCommand()=保存) 發(fā)現(xiàn)最后一句有問(wèn)題 改成 else if (e.getActionCommand()=保存) 七、課程設(shè)計(jì)總結(jié)由于未使用過(guò)JAVA進(jìn)行程序的編寫,因此,本次試驗(yàn)開始時(shí)無(wú)從下手。但通過(guò)此次課程設(shè)計(jì),我了解了許多JAVA軟件的應(yīng)用,包括:MyEclipse、Eclipse等等軟件的簡(jiǎn)單基本的操作。通過(guò)實(shí)際問(wèn)題的測(cè)試,使我進(jìn)一步了解了java的運(yùn)用.也發(fā)現(xiàn)了不少問(wèn)題了解了JAVA中的頭文件,類的相關(guān)定義,特別是string類等相關(guān)程序的應(yīng)用。本次實(shí)驗(yàn),也借助了網(wǎng)絡(luò),通過(guò)上網(wǎng)查閱了不少資料,也問(wèn)了網(wǎng)友很多問(wèn)題,一起探討解決.題目二:頁(yè)面調(diào)度算法OPT的模擬實(shí)現(xiàn)一、課題內(nèi)容和要求 內(nèi)容 虛擬存儲(chǔ)中頁(yè)面調(diào)度算法OPT的模擬實(shí)現(xiàn)。 要求 學(xué)習(xí)虛擬存儲(chǔ)機(jī)制中頁(yè)面調(diào)度算法,通過(guò)編程模擬實(shí)現(xiàn)頁(yè)面調(diào)度的OPT算法。2、 需求分析利用c+或者java等語(yǔ)言模擬實(shí)現(xiàn)頁(yè)面調(diào)度的opt算法,本人由于對(duì)java不是很熟悉,所以用了c+實(shí)現(xiàn)3、 概要設(shè)計(jì)首先實(shí)現(xiàn)文本文檔的建立, 建立分配的內(nèi)存空間,并初始化,返回頭結(jié)點(diǎn),利用指針進(jìn)行數(shù)字的調(diào)度調(diào)度成功,結(jié)束實(shí)驗(yàn)四、詳細(xì)設(shè)計(jì) 詳細(xì)代碼如下:#include #include #include #define null 0 #define len sizeof(struct page) struct page int num; int tag; struct page *next; ; struct page *create(int n) /*建立分配的內(nèi)存空間,并初始化,返回頭結(jié)點(diǎn)*/ int count=1; struct page *p1,*p2,*head; head=p2=p1=(struct page *)malloc(len); p1-tag=-1;p1-num=-1; while(counttag=-1;p1-num=-1; p2-next=p1; p2=p1; p2-next=null; return(head); OPT(array,n) int array,n; int *p,*q,count=0,i; struct page *head,*cp,*dp,*new; p=array; head=create(n); while(*p!=-1) cp=head; for(;cp-num!=*p&cp-next!=null;) cp=cp-next; if(cp-num!=*p) count+; cp=head; for(;cp-tag!=-1&cp-next!=null;) cp=cp-next; if(cp-tag=-1) printf( * ); cp-num=*p; cp-tag=0; else i=1;q=p;q+;cp=head; while(*q!=-1&inum&cp-next!=null;) cp=cp-next; if(*q=cp-num) cp-tag=1; i+; q+;cp=head; if(i=n) for(;cp-tag!=0;) cp=cp-next; printf( %d ,cp-num); cp-num=*p; else cp=head; for(;cp-tag!=0;) cp=cp-next; if(cp=head) for(;cp-next!=null;) cp=cp-next; new=(struct page *)malloc(len); new-num=*p; new-tag=0; new-next=null; cp-next=new; dp=head; head=head-next; printf( %d ,dp-num); free(dp); else printf( %d ,cp-num); cp-num=*p; cp=head; for(;cp-next!=null;) cp-tag=0;cp=cp-next; cp-tag=0; else printf( ! ); p+; printf(nQueye Zongshu : %d n,count); main() FILE *fp; char pt; char str10; int i,j=0; int page50,space=0; f
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 能源企業(yè)部分股權(quán)轉(zhuǎn)讓及新能源項(xiàng)目合作協(xié)議
- 文化活動(dòng)場(chǎng)地租賃合同終止及場(chǎng)地恢復(fù)協(xié)議
- 商業(yè)保險(xiǎn)理賠與財(cái)產(chǎn)分配合同
- 高端離婚子女撫養(yǎng)及財(cái)產(chǎn)分割協(xié)議
- 政府機(jī)構(gòu)公務(wù)車輛無(wú)償租賃使用協(xié)議
- 車輛事故責(zé)任承擔(dān)及經(jīng)濟(jì)賠償協(xié)議范本
- 精裝修住宅出租服務(wù)合同
- 北京科萬(wàn)物業(yè)裝修工程合同施工安全與質(zhì)量保障協(xié)議
- 酒店培訓(xùn)服務(wù)禮儀
- 2024年高考語(yǔ)文備考之掌握分析高考古詩(shī)題材技巧
- 2024-2025學(xué)年下學(xué)期高一化學(xué)蘇教版期末必刷??碱}之原電池與電解池
- 公司系統(tǒng)主數(shù)據(jù)管理制度
- 2025年煙臺(tái)市中考地理試卷真題(含答案及解析)
- 工廠安全手冊(cè)從火災(zāi)到其他事故的應(yīng)急響應(yīng)
- 肯德基服務(wù)管理制度
- 2025至2030中國(guó)微晶玻璃行業(yè)產(chǎn)業(yè)運(yùn)行態(tài)勢(shì)及投資規(guī)劃深度研究報(bào)告
- 部編版二年級(jí)語(yǔ)文下冊(cè)期末測(cè)試卷(含答案)
- 抖音精準(zhǔn)圈層種草
- 300MW單元機(jī)組過(guò)熱汽溫控制系統(tǒng)的設(shè)計(jì)
- (完整版)銷售人員銷售能力測(cè)試及答案解析
- 橋架、線槽支架重量計(jì)算表
評(píng)論
0/150
提交評(píng)論