JAVA高級程序設計課程設計任務書_第1頁
JAVA高級程序設計課程設計任務書_第2頁
JAVA高級程序設計課程設計任務書_第3頁
JAVA高級程序設計課程設計任務書_第4頁
JAVA高級程序設計課程設計任務書_第5頁
已閱讀5頁,還剩21頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、精選優(yōu)質文檔-傾情為你奉上存檔資料 成績: 廣西師范大學漓江學院課程設計報告書課程名稱:JAVA高級程序設計課程設計設計題目:基于C/S架構的聊天工具的設計與實現(xiàn)所在系部:理學系班 級:12計算機學號:學生姓名:指導教師:肖建明2014年 4 月 日專心-專注-專業(yè)課程設計(論文)評閱意見序號項 目等級優(yōu)秀良好中等及格不及格1課程設計態(tài)度及出勤情況2任務完成程度3設計中創(chuàng)新性4論文書寫規(guī)范化綜合評定等級課程設計軟件演示及答辯成績序號項 目等級優(yōu)秀良好中等及格不及格1演示過程完成情況2對軟件代碼熟悉情況3回答問題準確性和邏輯性綜合評定等級課程設計軟件界面及功能設計成績序號項 目等級優(yōu)秀良好中等及

2、格不及格1界面美觀及可操作性2功能實現(xiàn)情況及創(chuàng)新性3代碼的可讀性和可維護性綜合評定等級評閱人 年 月 日課程設計任務書一、本課程設計的目的1.使學生能夠更好地掌握Java程序設計語言和理解面向對象程序設計的基本概念與方法; 2.掌握類和對象的創(chuàng)建和使用,理解面向對象的封裝性、繼承性、多態(tài)性和面向接口編程的程序設計思想,學會利用Java語言和面向對象編程方法解決一般應用問題;3.從實踐中累積經(jīng)驗、培養(yǎng)學生分析、解決問題的能力;4.提高學生實踐論文撰寫能力。 5.初步掌握使用Java語言開發(fā)小型應用軟件的基本方法和步驟二、課程設計的教學過程與考核方法1課程設計以小項目的方式開展,以分組(1-2人一

3、組)的形式進行。2第一次實驗課時,任課教師下達課程設計題目任務,講解課程設計的題目要求和注意事項,并要求學生根據(jù)題目要求進行界面的設計和功能代碼編寫工作,完成課程設計報告。3課程設計實驗進行過程中,教師根據(jù)實驗的進度分模塊講述課程設計題目的設計要點。教師給予技術和方法上的指導,每個學生自己動手完成項目,并要求學生積極開展邏輯思維,充分發(fā)揮自己的創(chuàng)意,設計出優(yōu)秀的課程設計作品。4課程設計結束后,要求學生完成課程設計報告,課程設計報告需包括目錄、設計目標、實現(xiàn)思路、實現(xiàn)步驟、總結、參考文獻、附錄等;5最后需上交課程設計報告紙質版和電子版及設計的軟件作品源程序、數(shù)據(jù)庫和相關文檔,并進行軟件設計作品的

4、演示和答辯。三、課程設計評分標準1學習態(tài)度:10分;2系統(tǒng)設計:20分;3編程調試:25分;4回答問題:15分;5論文撰寫:30分。四、課程設計題目 基于C/S架構的聊天工具的設計與實現(xiàn)1.課程設計題目基本要求:(1)熟悉JAVA開發(fā)環(huán)境,掌握JAVA程序的編譯和運行;(2)掌握JAVA面向對象編程技術和方法;(3)掌握GUI圖形界面編程及事件處理機制;(4)了解異常處理機制(5)掌握Java數(shù)據(jù)庫編程方法和數(shù)據(jù)庫基本知識(6)掌握Java網(wǎng)絡編程方法和多線程編程方法 2.課程設計內容要求:要求編程實現(xiàn)一個類似QQ的網(wǎng)絡聊天工具軟件,該聊天工具可以同時跟多人聊天,聊天記錄保存在數(shù)據(jù)庫中,具有用

5、戶登錄、注冊,查看聊天記錄,離線留言,清除聊天記錄,查看在線用戶,查找用戶,添加好友等功能。目錄設計報告應包括整個設計中所采用的具體流程和步驟,以及任務完成的具體情況和取得的收獲。主要內容為:需求分析:分析闡述設計的要求以及對應到你要實現(xiàn)的系統(tǒng)應具有什么樣的功能??傮w設計:進一步提出自己解決問題的思路和方案。讓讀者了解方案的總體設計和關鍵技術。具體包括:總的設計思路,體系結構, 總體架構, 功能模塊圖;各功能模塊所要達到的設計目標的簡單介紹;設計的數(shù)據(jù)字典(數(shù)據(jù)庫、表的結構);軟硬件環(huán)境和開發(fā)技術和平臺等。詳細設計:對整個開發(fā)工作的內容進行詳細的介紹。一般按照功能模塊分成幾部分來介紹。每部分應

6、包括文字敘述、界面圖片、關鍵實現(xiàn)技術(操作或代碼)等幾個方面綜合說明問題。系統(tǒng)調試與測試:介紹設計過程中遇到的問題和解決方法。如何測試系統(tǒng),測試中發(fā)現(xiàn)的問題和解決方案??偨Y:對整個設計中做的工作、獲得的成果、心得體會等做一個簡單小結。 基于C/S架構的聊天工具的設計與實現(xiàn)需求分析:在當今信息時代,越來越多的聊天工具被應用,java語言是當今流行的網(wǎng)絡編程語言,它具有面向對象,與平臺無關,安全,多線程等特點。使用java語言不僅可以實現(xiàn)大型企業(yè)級的分布式應用系統(tǒng),還能夠為小型的的,嵌入式設備進行應用程序的開發(fā)。面向對象的開發(fā)是當今世界最流行的開發(fā)方法,它不僅具有更貼近自然地語義,而且有利于軟件的

7、維護和繼承,鍛煉我們熟練地應用面向對象的思想和設計方法解決實際問題的能力。本程序正是用java語言實現(xiàn)了簡單聊天功能。它是圖形界面,線程,流與文件系統(tǒng)等技術的綜合應用。其界面主要采用了java.awt包,java.swing包等。總體設計:本軟件實現(xiàn)的功能有1.允許服務器偵聽客戶端,客戶端連接到服務器2.允許服務區(qū)與客戶端之間進行聊天; 3.服務器與客戶端時,會顯示內容發(fā)送時間;4.允許服務器與客戶端用鼠標點擊“發(fā)送”可發(fā)送內容5.允許服務器與客戶端用鼠標點擊關閉時關閉聊天窗口服務器和客戶端登陸以及客戶端群聊界面利用java語言的AWT和Swing實現(xiàn),聊天功能利用java語言網(wǎng)絡編程的多線程

8、和網(wǎng)絡編程的知識實現(xiàn)。詳細設計:本系統(tǒng)中我們利用Java實現(xiàn)基于C/S模式的聊天室系統(tǒng),分為服務器端和客戶端兩部分,運用Socket套接字實現(xiàn)客戶方和服務方的鏈接,服務器端通過端口設置在特定端口上進行監(jiān)聽,等待客戶端的連接,一旦客戶端連接成功,則可以向連接成功的用戶發(fā)送系統(tǒng)消息,可以接收所有客戶端發(fā)送的消息并顯示;客戶端則與服務器端規(guī)定的端口進行連接,連接成功后可以登錄,登錄成功后便可以和所選的對象聊天,可以發(fā)送信息,也可以接收聊天對象所發(fā)送過來的信息,并顯示信息內容。程序中引入的包:import java.awt.*;import java.awt.event.*;import javax.

9、swing.*;import .*;import java.io.*;源代碼package xjm;import java.awt.BorderLayout;import java.awt.FlowLayout; import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JPanel;import javax.swing.border.EmptyBorder;import javax.swing.JTextArea;import javax.swing.JScrollPane;import java.awt

10、.Color;import javax.swing.border.BevelBorder;import javax.swing.border.CompoundBorder;import javax.swing.border.EtchedBorder;import javax.swing.border.SoftBevelBorder;import javax.swing.border.TitledBorder;import javax.swing.ScrollPaneConstants;import java.awt.event.ActionListener;import java.awt.ev

11、ent.ActionEvent;import java.io.BufferedReader;import java.io.IOException;import java.io.PrintWriter;import .ServerSocket;import .Socket;import java.util.ArrayList; public class ChatServer extends JDialog private final JPanel contentPanel = new JPanel();/以下創(chuàng)建網(wǎng)絡相關變量 int serverPort=2345;ServerSocket se

12、rverSocket=null;/Socket socket=null;BufferedReader socketIn;PrintWriter socketOut; boolean isstarting=false;JButton okButton=null;JTextArea textArea_info;ArrayList clientList=new ArrayList();/* * Launch the application. */public static void main(String args) try ChatServer dialog = new ChatServer();

13、dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);dialog.setVisible(true); catch (Exception e) e.printStackTrace();/* * Create the dialog. */public ChatServer() setTitle(u804Au5929u670Du52A1u5668);setBounds(100, 100, 641, 365);getContentPane().setLayout(new BorderLayout();contentPanel.setBor

14、der(new BevelBorder(BevelBorder.LOWERED, null, null, null, null);getContentPane().add(contentPanel, BorderLayout.CENTER);contentPanel.setLayout(null);JScrollPane scrollPane = new JScrollPane();scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);scrollPane.setHorizont

15、alScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);scrollPane.setBounds(10, 10, 613, 278);contentPanel.add(scrollPane);textArea_info = new JTextArea();scrollPane.setViewportView(textArea_info);textArea_info.setBackground(new Color(224, 255, 255);textArea_info.setText(u670Du52A1u5668u

16、901Au8BAFu8BB0u5F55);textArea_info.setForeground(Color.BLUE);JPanel buttonPane = new JPanel();buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT);getContentPane().add(buttonPane, BorderLayout.SOUTH);okButton = new JButton(u542Fu52A8);/啟動okButton.addActionListener(new ActionListener() public void a

17、ctionPerformed(ActionEvent arg0) if (serverSocket=null) try serverSocket=new ServerSocket(serverPort);isstarting=true;okButton.setEnabled(false);new Thread(new Runnable() Overridepublic void run() int i=1;/ TODO 自動生成的方法存根while(isstarting)try Socket socket;socket = serverSocket.accept();SocketThread

18、socketThread=new SocketThread(socket);socketThread.setTextArea_handle(textArea_info);socketThread.setClientList(clientList);socketThread.start();/System.out.println(i+); catch (IOException e) / TODO 自動生成的 catch 塊e.printStackTrace();isstarting=false;okButton.setEnabled(true);).start(); catch (IOExcep

19、tion e) / TODO 自動生成的 catch 塊e.printStackTrace();try if (serverSocket!=null) serverSocket.close(); catch (IOException e1) / TODO 自動生成的 catch 塊/e1.printStackTrace(););JButton clearButton = new JButton(u6E05u8BB0u5F55);clearButton.addActionListener(new ActionListener() public void actionPerformed(Actio

20、nEvent e) textArea_info.setText(););buttonPane.add(clearButton);okButton.setActionCommand(OK);buttonPane.add(okButton);getRootPane().setDefaultButton(okButton);JButton cancelButton = new JButton(u9000u51FA);cancelButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e

21、) try if (serverSocket!=null) serverSocket.close(); catch (IOException e1) / TODO 自動生成的 catch 塊/e1.printStackTrace();System.exit(0););cancelButton.setActionCommand(Cancel);buttonPane.add(cancelButton); 系統(tǒng)調試與測試:總結:1通過本次課程設計,使得自己懂得理論和實踐相結合起來,從理論中得出結論,才能真正掌握這門技術,也提高了自己獨立思考的能力,在設計的過程中,可以自己解決。真正體會到要將一門知識

22、學的更深入,必須加強實踐,多練習,才能發(fā)現(xiàn)問題所在。2.本程序實現(xiàn)的功能還比較簡單不夠完善,從中,我知道了自己的不足之處,決心增長自己的知識,設計更加好的程序,實現(xiàn)各種更加復雜的功能,如:傳輸文件,圖片。以及登陸界面,昵稱等。3總的來說,這次實訓對我很有幫助。讓我學會了的不只是設計JAVA聊天器,更讓我學會主動學習,而不是被動接收。這樣才能更好的運用自己所學到的知識。參考文獻1 袁紹欣等編著. Java面向對象程序設計(第二版).北京:清華大學出版社,2012.6附 錄程序主要源代碼:package xjm;import java.awt.BorderLayout;import java.aw

23、t.FlowLayout; import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JPanel;import javax.swing.border.EmptyBorder;import javax.swing.JTextArea;import javax.swing.JScrollPane;import java.awt.Color;import javax.swing.border.BevelBorder;import javax.swing.border.CompoundBorder;import

24、javax.swing.border.EtchedBorder;import javax.swing.border.SoftBevelBorder;import javax.swing.border.TitledBorder;import javax.swing.ScrollPaneConstants;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.io.BufferedReader;import java.io.IOException;import java.io.Print

25、Writer;import .ServerSocket;import .Socket;import java.util.ArrayList; public class ChatServer extends JDialog private final JPanel contentPanel = new JPanel();/以下創(chuàng)建網(wǎng)絡相關變量 int serverPort=2345;ServerSocket serverSocket=null;/Socket socket=null;BufferedReader socketIn;PrintWriter socketOut; boolean is

26、starting=false;JButton okButton=null;JTextArea textArea_info;ArrayList clientList=new ArrayList();/* * Launch the application. */public static void main(String args) try ChatServer dialog = new ChatServer();dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);dialog.setVisible(true); catch (Exc

27、eption e) e.printStackTrace();/* * Create the dialog. */public ChatServer() setTitle(u804Au5929u670Du52A1u5668);setBounds(100, 100, 641, 365);getContentPane().setLayout(new BorderLayout();contentPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null);getContentPane().add(content

28、Panel, BorderLayout.CENTER);contentPanel.setLayout(null);JScrollPane scrollPane = new JScrollPane();scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);scrollPane.setBounds(10, 1

29、0, 613, 278);contentPanel.add(scrollPane);textArea_info = new JTextArea();scrollPane.setViewportView(textArea_info);textArea_info.setBackground(new Color(224, 255, 255);textArea_info.setText(u670Du52A1u5668u901Au8BAFu8BB0u5F55);textArea_info.setForeground(Color.BLUE);JPanel buttonPane = new JPanel()

30、;buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT);getContentPane().add(buttonPane, BorderLayout.SOUTH);okButton = new JButton(u542Fu52A8);/啟動okButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) if (serverSocket=null)try serverSocket=new ServerSocket(serv

31、erPort);isstarting=true;okButton.setEnabled(false);new Thread(new Runnable() Overridepublic void run() int i=1;/ TODO 自動生成的方法存根while(isstarting)try Socket socket;socket = serverSocket.accept();SocketThread socketThread=new SocketThread(socket);socketThread.setTextArea_handle(textArea_info);socketThr

32、ead.setClientList(clientList);socketThread.start();/System.out.println(i+); catch (IOException e) / TODO 自動生成的 catch 塊e.printStackTrace();isstarting=false;okButton.setEnabled(true);).start(); catch (IOException e) / TODO 自動生成的 catch 塊e.printStackTrace();try if (serverSocket!=null) serverSocket.close

33、(); catch (IOException e1) / TODO 自動生成的 catch 塊/e1.printStackTrace(););JButton clearButton = new JButton(u6E05u8BB0u5F55);clearButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) textArea_info.setText(););buttonPane.add(clearButton);okButton.setActionCommand(OK);

34、buttonPane.add(okButton);getRootPane().setDefaultButton(okButton);JButton cancelButton = new JButton(u9000u51FA);cancelButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) try if (serverSocket!=null) serverSocket.close(); catch (IOException e1) / TODO 自動生成的 catch

35、塊/e1.printStackTrace();System.exit(0););cancelButton.setActionCommand(Cancel);buttonPane.add(cancelButton);package xjm;import java.awt.BorderLayout;import java.awt.FlowLayout;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.s

36、wing.JPasswordField;import javax.swing.border.EmptyBorder;import javax.swing.JLabel;import javax.swing.JTextField;import java.awt.Color;import javax.swing.SwingConstants;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;public class LoginDialog extends JDialog private LoginDialo

37、g loginDialog=this;private final JPanel contentPanel = new JPanel();private JTextField textField_username;private JPasswordField textField_password;private JTextField textField_serverIP;/* * Launch the application. */public static void main(String args) try LoginDialog dialog = new LoginDialog();dia

38、log.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);dialog.setVisible(true); catch (Exception e) e.printStackTrace();/* * Create the dialog. */public LoginDialog() setForeground(Color.CYAN);setTitle(u7528u6237u767Bu5F55u7A97u53E3);setBounds(100, 100, 325, 215);getContentPane().setLayout(new Borde

39、rLayout();contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5);getContentPane().add(contentPanel, BorderLayout.CENTER);contentPanel.setLayout(null);JLabel label = new JLabel(u7528u6237u540Du79F0uFF1A);label.setHorizontalAlignment(SwingConstants.RIGHT);label.setForeground(Color.BLUE);label.setBounds(41

40、, 59, 89, 15);contentPanel.add(label);JLabel label_1 = new JLabel(u767Bu5F55u5BC6u7801uFF1A);label_1.setHorizontalAlignment(SwingConstants.RIGHT);label_1.setForeground(Color.BLUE);label_1.setBounds(41, 94, 89, 15);contentPanel.add(label_1);textField_username = new JTextField();textField_username.set

41、ToolTipText(u7528u6237u540Du79F0u533Au5206u5927u5C0Fu5199uFF01);textField_username.setBounds(140, 56, 120, 21);contentPanel.add(textField_username);textField_username.setColumns(10);textField_password = new JPasswordField();textField_password.setToolTipText(u8BF7u8F93u5165u767Bu5F55u5BC6u7801uFF01);

42、textField_password.setBounds(140, 91, 120, 21);contentPanel.add(textField_password);textField_password.setColumns(10);JLabel lblip = new JLabel(u670Du52A1u5668IPuFF1A);lblip.setHorizontalAlignment(SwingConstants.RIGHT);lblip.setForeground(Color.BLUE);lblip.setBounds(41, 21, 89, 15);contentPanel.add(lblip);textField_serverIP = new JTe

溫馨提示

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

評論

0/150

提交評論