1、面向對象程序設計ii -j2me課程設計論文題 目:課程表管理系統(tǒng)學 院:計算機與信息工程學院專 業(yè):計算機科學與技術班 級:計算機06-7班姓 名:徐興安學 號:21起止時間:2008.12.21-2008.12.31 成績: 課程設計成績評定表質量評價指標(在相應欄目打)評 價 項 目評 價 質 量優(yōu)秀良好一般及格不及格工作量和態(tài)度實驗、計算可靠性文字和圖表質量程序完成情況總體評價評定成績評定人員簽名2008年12月31日iv課程設計任務書一、設計題目:課程表管理系統(tǒng)二、設計內容:課程表管理系統(tǒng)是管理我們日常課程的軟件,它可以用來記錄、查看、修改課程名字、上課時間、上課地點;查看今天課程,
2、上課地點,任課教師等功能。三、設計要求:1主界面顯示用戶可操作的基本功能,創(chuàng)建新課程,顯示所有課程,查詢某天課程,使用說明等。2應用程序啟動后顯示當天的所有課程,標題顯示今天是哪一天,以及第幾周,周幾,按2,4,6,8鍵可以顯示昨天或者明天的課程,按返回則顯示今天的課表點擊相應的菜單項可以進入相應功能界面。3選擇好某天之后,點擊修改即可,只有選擇的天是星期一才能設置成功,在課程安排里,*表示該節(jié)課上這個課,按選擇鍵可以選擇或者去除選擇。4所有課程界面將列出所有已經創(chuàng)建好的課程,有兩個菜單項,一個刪除選擇的課程,一個編輯所選的課程,選擇好某天后,按查看即可查看那天的課程。四、工作計劃:時間完成內
3、容提交文檔備注第1天查找資料,確定題目,選擇方案課程設計任務書設計準備階段第2天第3天題目分析,設計算法算法描述設計階段第4天功能模塊的劃分和設計結構流程圖等第5天第6天實現(xiàn)具體數(shù)據(jù)結構和模塊無第7天程序設計與調試無運行并驗證程序功能第8天第9天檢查程序第10天整理材料,撰寫論文課程設計論文指導教師: 王艷濤 陳偉 高輝 教研室主任: 2008 年 12月31 日ii 本科課程設計論文摘 要課程表管理系統(tǒng)是管理我們日常課程的軟件,它可以用來記錄、查看、修改課程名字、上課時間、上課地點;查看今天課程,上課地點,任課教師等功能。關鍵詞:j2me 面向對象 課程表iii目 錄課程設計成績評定表ii課
4、程設計任務書iii摘 要ii目 錄iii1 設計內容32 設計過程32.1設計方案的論證32.2概要設計22.3界面設計圖22.4代碼實現(xiàn)53 設計總結5參考文獻6附錄:程序源代碼61 設計內容課程表管理系統(tǒng)是管理我們日常課程的軟件,它可以用來記錄、查看、修改課程名字、上課時間、上課地點;查看今天課程,上課地點,任課教師等功能。2 設計過程2.1設計方案的論證eclipse是當今最流行的java開發(fā)ide之一,它是一個開發(fā)源代碼的、基于java的可擴展開發(fā)平臺,因為它具有良好的可擴展性。 它是一個開發(fā)源代碼的、基于java的可擴展開發(fā)平臺,因為它具有良好的可擴展性.j2me開發(fā)可以繼承在ecl
5、ipse中完成,利用eclipse界面友好的優(yōu)勢,提高j2me應用程序的開發(fā)效率。eclipse框架的這種靈活性來源于其擴展點。它們是在xml中定義的已知接口,并充當插件的耦合點。擴展點的范圍包括從用在常規(guī)表述過濾器中的簡單字符串,到一個java類的描述。任何eclipse插件定義的擴展點都能夠被其它插件使用,反之,任何eclipse插件也可以遵從其它插件定義的擴展點。除了解由擴展點定義的接口外,插件不知道它們通過擴展點提供的服務將如何被使用。 eclipse的最大特點是它能接受由java開發(fā)者自己編寫的開放源代碼插件,這類似于微軟公司的visual studio和sun微
6、系統(tǒng)公司的netbeans平臺。eclipse為工具開發(fā)商提供了更好的靈活性,使他們能更好地控制自己的軟件技術。2.2概要設計本程序共有18個java源文件:course.java:此類是一個課程,包括課程的所有信息。.mydate.java:該文件用來存儲日期信息。onecoursetable.java:該類完成存儲某一個課程一個星期的上課情況內容。table.java.java:該類完成存儲某一天要上的課的信息。allcourses.java:列出已存在課程。editcourse.java:編輯某一門課程的時候顯示的form。findform.java:查看某天課程的時候顯示的form 有
7、一個datefield對象。menulist.java:用于顯示主菜單。.newcourse.java:創(chuàng)建一個新課程的界面。onedaycourseform.java:顯示今天的所有課程。readmeform.java:程序使用說明。startweek.java:設置開學第一天的日期。coursebydaysfilter.java:比較用到的有第幾周,星期幾。coursefilter.java:比較用到的有課程名。myrms.java:所有對rms操作的方法都在這里 全部都設成靜態(tài)方法。operationtocalendar.java:用于顯示方便,根據(jù)數(shù)字來得到它是星期幾。operatio
8、ntorms.java:該文件負責創(chuàng)建提示界面。coursetable.java:midlet程序啟動時執(zhí)行的類。2.3界面設計圖(1) 應用程序啟動后顯示當天的所有課程,標題顯示今天是哪一天,以及第幾周,周幾,按2,4,6,8鍵可以顯示昨天或者明天的課程,按返回會返回到主菜單界面,如圖1所示(2) 主菜單界面如圖2所示,按返回則顯示今天的課表點擊相應的菜單項可以進入相應功能界面(3) 設置開學第一天的界面如圖3所示,選擇好某天之后,點擊修改即可,只有選擇的天是星期一才能設置成功(4) 創(chuàng)建新課程界面如圖4所示,在課程安排里,*表示該節(jié)課上這個課,按選擇鍵可以選擇或者去除選擇(5) 所有課程界
9、面如圖5所示,它將列出所有已經創(chuàng)建好的課程,有兩個菜單項,一個刪除選擇的課程,一個編輯所選的課程,編輯界面與圖4相似(6) 查詢某天課程如圖6所示,選擇好某天后,按查看即可查看那天的課程(7) 程序說明界面如圖7所示,它介紹了該程序如何使用 圖1 今天的課程圖2 主菜單界面圖3開學第一天界面圖4創(chuàng)建新課程界面圖5所有課程界面圖6查看某天課程界面圖7使用說明界面2.4代碼實現(xiàn)mydate類為了方便計算,自己設計了一個mydate類,來存儲日期信息,它共有3個字段:year,month,dayofmonth;tobytes用于將日期信息轉化為字節(jié)數(shù)組 initmydate 用傳入的字節(jié)數(shù)組來設置這
10、個日期的字段public class mydate private int year; private int month; private int dayofmonth; public mydate(int year,int month,int dayofmonth) this.year=year; this.month=month; this.dayofmonth=dayofmonth; public mydate() this.year=2008; this.month=1; this.dayofmonth=18; public byte tobytes() byte data = nu
11、ll; try bytearrayoutputstream baos = new bytearrayoutputstream(); dataoutputstream dos = new dataoutputstream(baos); dos.writeint(year); dos.writeint(month); dos.writeint(dayofmonth); data = baos.tobytearray(); baos.close(); dos.close(); catch (exception e) e.printstacktrace(); return data; public v
12、oid initmydate(byte data) try bytearrayinputstream bais = new bytearrayinputstream(data); datainputstream dis = new datainputstream(bais); year = dis.readint(); month = dis.readint(); dayofmonth = dis.readint(); bais.close(); dis.close(); catch (ioexception ex) ex.printstacktrace(); public int getda
13、yofmonth() return dayofmonth; public int getmonth() return month; public int getyear() return year; 經過前面的工作,最后在集成編輯環(huán)境中,編寫的程序代碼見附錄程序所示。3 設計總結在老師的指導下,運用老師課堂上講的知識,我們設計出了課程表管理系統(tǒng)。這次課程設計是對這學期j2me課程的一個知識綜合,它需要運用到前面所學的知識。通過這次課程設計,使我們將平時所學的知識運用到實踐中,提高了自己實際上機操作的能力。在實際操作中發(fā)現(xiàn)平時的知識的不足。總之,這是對平時掌握知識的一次檢驗,也是一次對平時不足的
14、彌補。感謝老師這學期對課本知識和做人為事的教導使我們在輕松愉快中掌握了j2me的基本操作。參考文獻1 j2me手機游戲開發(fā)技術詳解出版社:清華大學出版社 李振鵬 龔劍 編著2 j2me開發(fā)精解 出版社:電子工業(yè)出版社詹建飛 編著3 j2me移動應用開發(fā)出版社: 北方交通大學出版 郝玉龍,李向前 編著4 j2me 程序開發(fā)實用案例從入門到精通出版社: 清華大學出版社王曉 王天順 等編著附錄:程序源代碼package entities;import java.io.bytearrayinputstream;import java.io.bytearrayoutputstream;import ja
15、va.io.datainputstream;import java.io.dataoutputstream;import java.io.ioexception;/* * * 此類是一個課程,包括課程的所有信息:課程名,起始周,結束周,上課教室,以及一周的哪一天哪節(jié)課上課 * tobytes用于將一個課程對象轉化為字節(jié)數(shù)組 * 有3個靜態(tài)方法,deserialize可以將字節(jié)數(shù)組轉化為一個課程 * matchcourse用于判斷一個字節(jié)數(shù)組所代表的課程的課程名與另一個課程名進行比較,它會被一個實現(xiàn)了recordfilter的類調用,以實現(xiàn) * 選擇字節(jié)數(shù)組里含有該名字的字節(jié)數(shù)組 * match
16、coursebaydays用于判斷一個字節(jié)數(shù)組的信息與一個第幾周,周幾來比較,用于判斷該天是否有這個課,它也會被一個實現(xiàn)了recordfilter的類調用 * ,以選擇特定的字節(jié)數(shù)組 */public class course private string coursename; private int coursestartweek; private int courseendweek; private string courseroom; private int coursedata; public course(string coursename, int coursestartweek
17、, int courseendweek, string courseroom, int coursedata) this.coursestartweek = coursestartweek; this.courseendweek = courseendweek; this.courseroom = courseroom; this.coursedata = coursedata; this.coursename=coursename; public course(string help) this.coursename="" this.courseroom="&q
18、uot; this.coursestartweek=1; this.courseendweek=2; for(int i=0;i<5;i+) for(int j=0;j<7;j+) this.coursedataij=0; /*與數(shù)據(jù)流以及rms有關的一些函數(shù)*/ public byte tobytes() byte data = null; try bytearrayoutputstream baos = new bytearrayoutputstream(); dataoutputstream dos = new dataoutputstream(baos); dos.writ
19、eutf(coursename);/1.寫課程名字 dos.writeutf(courseroom);/2.寫上課教室 dos.writeint(coursestartweek);/3.寫課程起始周 dos.writeint(courseendweek);/4.寫課程結束周 /5.寫課程數(shù)據(jù) 按行寫入 for(int i=0;i<coursedata.length;i+) for(int j=0;j<coursedatai.length;j+) dos.writeint(coursedataij); data = baos.tobytearray(); baos.close();
20、dos.close(); catch (exception e) e.printstacktrace(); return data; /將課程信息轉換為字節(jié)數(shù)組 public static course deserialize(byte data) int acoursedata=new int57; for(int i=0;i<5;i+) for(int j=0;j<7;j+) acoursedataij=0; course course=new course("",1,2,"",acoursedata); try bytearrayinp
21、utstream bais = new bytearrayinputstream(data); datainputstream dis = new datainputstream(bais); course.coursename=dis.readutf();/1.讀課程名字 course.courseroom=dis.readutf(); /2.讀上課教室 course.coursestartweek=dis.readint();/3.讀課程起始周 course.courseendweek=dis.readint(); /4.讀課程結束周 /5.讀課程數(shù)據(jù) 按行讀出 for(int i=0;i
22、<5;i+) for(int j=0;j<7;j+) course.coursedataij=dis.readint(); bais.close(); dis.close(); catch (ioexception ex) ex.printstacktrace(); return course; /將字節(jié)數(shù)組轉化為課程信息 public static boolean matchcourse(byte data,string coursename)throws ioexception boolean success=false; try bytearrayinputstream ba
23、is = new bytearrayinputstream(data); datainputstream dis = new datainputstream(bais); success = dis.readutf().equals(coursename); bais.close(); dis.close(); catch(ioexception ex) ex.printstacktrace(); return success; /判斷一個字節(jié)數(shù)組里是否有coursename這個課程 public static boolean matchcoursebydays(bytedata,int we
24、ekofterm,int tempdayofweek) boolean success=false; course course=deserialize(data); int acoursedata=course.getcoursedata(); int weeknum=weekofterm; int dayofweek; if(tempdayofweek>1) dayofweek=tempdayofweek-1; else dayofweek=7; if(course.getcoursestartweek()<=weeknum&&weeknum<=cours
25、e.getcourseendweek() int i=0; while(i<5) if(acoursedataidayofweek-1=1) success=true; break; i+; return success; /判斷一個字節(jié)數(shù)組里今天是否有課 /*與數(shù)據(jù)流以及rms有關的一些函數(shù)結束*/ public int getcoursedata() return coursedata; public int getcourseendweek() return courseendweek; public string getcoursename() return coursename
26、; public string getcourseroom() return courseroom; public int getcoursestartweek() return coursestartweek; package entities;import java.io.bytearrayinputstream;import java.io.bytearrayoutputstream;import java.io.datainputstream;import java.io.dataoutputstream;import java.io.ioexception;/* * * 為了方便計算
27、,自己設計了一個類,來存儲日期信息,它共有3個字段:year,month,dayofmonth; * tobytes用于將日期信息轉化為字節(jié)數(shù)組 * initmydate 用傳入的字節(jié)數(shù)組來設置這個日期的字段 */public class mydate private int year; private int month; private int dayofmonth; public mydate(int year,int month,int dayofmonth) this.year=year; this.month=month; this.dayofmonth=dayofmonth; p
28、ublic mydate() this.year=2008; this.month=1; this.dayofmonth=18; public byte tobytes() byte data = null; try bytearrayoutputstream baos = new bytearrayoutputstream(); dataoutputstream dos = new dataoutputstream(baos); dos.writeint(year); dos.writeint(month); dos.writeint(dayofmonth); data = baos.tob
29、ytearray(); baos.close(); dos.close(); catch (exception e) e.printstacktrace(); return data; public void initmydate(byte data) try bytearrayinputstream bais = new bytearrayinputstream(data); datainputstream dis = new datainputstream(bais); year = dis.readint(); month = dis.readint(); dayofmonth = di
30、s.readint(); bais.close(); dis.close(); catch (ioexception ex) ex.printstacktrace(); public int getdayofmonth() return dayofmonth; public int getmonth() return month; public int getyear() return year; package entities;import javax.microedition.lcdui.*;/* * 該類完成存儲某一個課程一個星期的上課情況內容,并完成了顯示功能 * 它繼承自custo
31、mitem 是 diplayalbe子類,因此能以表格顯示 * setcoursedata 設置該表格里內容 * getcoursedata 則返回表格內容 * data字符串數(shù)組用于顯示 “*” 或者顯示空 它是6行8列數(shù)組 它還要顯示表頭 星期幾 以及第幾節(jié)課 * courseata整型數(shù)組,真正用于存儲數(shù)據(jù),為1則有課,否則沒課,它只是5行7列的數(shù)組 */* * */public class onecoursetable extends customitem implements itemcommandlistener private static final command cmd_e
32、dit = new command("編輯", command.item, 1); private static final int upper = 0; private static final int in = 1; private static final int lower = 2; private int rows = 6; private int cols = 8; private int dx = 25; private int dy = 20; private int location = upper; private int currentx = 1; p
33、rivate int currenty = 1; private string data = new stringrowscols; private int coursedata=new introws-1cols-1; / traversal stuff / indicating support of horizontal traversal internal to the customitem boolean horz; / indicating support for vertical traversal internal to the customitem. boolean vert;
34、 public onecoursetable(string title) super(title); setdefaultcommand(cmd_edit); setitemcommandlistener(this); /星期 data01="一"data02="二"data03="三"data04="四"data05="五" data06="六"data07="日" data10="1"data20="2"data
35、30="3"data40="4"data50="5" for(int i=0;i<5;i+) for(int j=0;j<7;j+) coursedataij=0; int interactionmode = getinteractionmodes(); horz = (interactionmode & customitem.traverse_horizontal) != 0); vert = (interactionmode & customitem.traverse_vertical) != 0);
36、public onecoursetable(string title,int a) super(title); setdefaultcommand(cmd_edit); setitemcommandlistener(this); /星期 data01="一"data02="二"data03="三"data04="四"data05="五" data06="六"data07="日" data10="1"data20="2"
37、;data30="3"data40="4"data50="5" for(int i=0;i<5;i+) for(int j=0;j<7;j+) coursedataij=aij; if(coursedataij!=0) datai+1j+1="*" int interactionmode = getinteractionmodes(); horz = (interactionmode & customitem.traverse_horizontal) != 0); vert = (interac
38、tionmode & customitem.traverse_vertical) != 0); protected int getmincontentheight() return (rows * dy) + 1; protected int getmincontentwidth() return (cols * dx) + 1; protected int getprefcontentheight(int width) return (rows * dy) + 1; protected int getprefcontentwidth(int height) return (cols
39、* dx) + 1; protected void paint(graphics g, int w, int h) for (int i = 0; i <= rows; i+) g.drawline(0, i * dy, cols * dx, i * dy); for (int i = 0; i <= cols; i+) g.drawline(i * dx, 0, i * dx, rows * dy); int oldcolor = g.getcolor(); g.setcolor(0x00d0d0d0); g.fillrect(currentx * dx) + 1, (curre
40、nty * dy) + 1, dx - 1, dy - 1); g.setcolor(oldcolor); for (int i = 0; i < rows; i+) for (int j = 0; j < cols; j+) if (dataij != null) / store clipping properties int oldclipx = g.getclipx(); int oldclipy = g.getclipy(); int oldclipwidth = g.getclipwidth(); int oldclipheight = g.getclipheight()
41、; g.setclip(j * dx) + 1, i * dy, dx - 1, dy - 1); g.drawstring(dataij, (j * dx) + 2, (i + 1) * dy) - 2, graphics.bottom | graphics.left); / restore clipping properties g.setclip(oldclipx, oldclipy, oldclipwidth, oldclipheight); protected boolean traverse(int dir, int viewportwidth, int viewportheigh
42、t, int visrect_inout) if (horz && vert) switch (dir) case canvas.down: if (location = upper) location = in; else if (currenty < (rows - 1) currenty+; repaint(currentx * dx, (currenty - 1) * dy, dx, dy); repaint(currentx * dx, currenty * dy, dx, dy); else location = lower; return false; break; case
評論
0/150
提交評論