课程设计--火灾报警系统_第1页
课程设计--火灾报警系统_第2页
课程设计--火灾报警系统_第3页
课程设计--火灾报警系统_第4页
课程设计--火灾报警系统_第5页
已阅读5页,还剩31页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、目录一、需求分析2二、概要设计2三、详细设计3四、调试分析15五、用户手册15六、测试数据15七、附录18一、需求分析编写一个模拟火灾报警的系统,要求能够做到完成报警编号的录入,删除,修改,查询,删除功能,在某个地点按下报警,会显示出该地点的报警,并有报警声音。程序执行的命令:1. 进入系统的登录界面2. 进入系统后的界面选择3. 实现报警二、概要设计1. 功能模块图:火灾报警管理系统 报警模拟报警点的删除报警点的录入 2. 构程序中所使用的数据结构的介绍class GongNengJieMian extends Frame implements ActionListener /实现登录的主界

2、面public class DBConnect /数据源类3 本程序模块结构class GongNengJieMian extends Frame implements ActionListener /主界面程序模块class tianjia extends Frame implements ActionListener/添加报警点的程序模块class ShanChu extends Frame implements ActionListener/删除报警点的程序模块class MoNi extends Frame implements ActionListener/模拟报警的程序模块publ

3、ic class A extends JFrame /地图的现实的程序模块各模块之间的调用关系如下:主程序模块 数据的更新模块 报警模拟模块 3 详细设计各功能模块的实现如下1. 主函数public class Mainpublic static void main(String args) new ZhuJieMian();/调用主界面类 2. 主界面public class ZhuJieMian extends Frame implements ActionListener private static final long serialVersionUID = 1L;/设置容器的大小Bu

4、ttonb1,b2;Label l1;Box bo,bo1;Panel p,p1;ZhuJieMian()super("主界面");b1=new Button("进入系统");b2=new Button("退出系统");l1=new Label("欢迎进入火灾报警模拟系统");p=new Panel();p1=new Panel();l1.setAlignment(Label.CENTER);l1.setFont(new Font("Serif",Font.PLAIN,40);l1.setFor

5、eground(Color.red);b1.setForeground(Color.red);b2.setForeground(Color.red);b1.setFont(new Font("Serif",Font.PLAIN,20);b2.setFont(new Font("Serif",Font.PLAIN,20);bo1=Box.createVerticalBox();bo1.add(Box.createVerticalStrut(50);bo1.add(l1);bo1.add(Box.createVerticalStrut(10);p1.add(

6、bo1);bo=Box.createVerticalBox();bo.add(b1);bo.add(Box.createVerticalStrut(20);bo.add(b2);bo.add(Box.createVerticalStrut(50);p.add(bo);add(p1,BorderLayout.NORTH);add(p,BorderLayout.SOUTH);b1.addActionListener(this);b2.addActionListener(this);setBounds(0,0,600,400);setVisible(true);this.addWindowListe

7、ner(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=b1)new GongNengJieMian();if(e.getSource()=b2)super.setVisible(false);3. 功能界面class GongNengJieMian extends Frame implements ActionListener Button b1,b2,b3,b4;Box

8、b;GongNengJieMian()super("功能选择界面");b1=new Button(" 添加火灾报警点 ");b2=new Button(" 删除火灾报警点 ");b3=new Button(" 火灾报警模拟");b4=new Button(" 退出 ");b=Box.createVerticalBox();b.add(Box.createVerticalStrut(40);b.add(b1);b.add(Box.createVerticalStrut(40);b.add(b2);

9、b.add(Box.createVerticalStrut(40);b.add(b3);b.add(Box.createVerticalStrut(40);b.add(b4);add(b);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);setLayout(new FlowLayout();setBounds(0,0,300,400);setVisible(true);validate();this.addWindowListe

10、ner(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=b1)new tianjia();if(e.getSource()=b2)new ShanChu();if(e.getSource()=b3)new MoNi();if(e.getSource()=b4)super.setVisible(false);4. 删除界面class ShanChu extends Frame

11、implements ActionListenerBox bo,bo1,bo2;Button b1,b2;JTextField t1;ShanChu()super("删除火灾报警点");t1=new JTextField(15);b1=new Button("确定");b2=new Button("返回");bo1=Box.createVerticalBox();bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点编号");bo1.add(Box.cr

12、eateVerticalStrut(40);bo1.add(b1);bo2=Box.createVerticalBox();bo2.add(Box.createVerticalStrut(40);bo2.add(t1);bo2.add(Box.createVerticalStrut(40);bo2.add(b2);bo=Box.createHorizontalBox();bo.add(bo1);bo.add(Box.createHorizontalStrut(20);bo.add(bo2);bo.add(Box.createHorizontalStrut(20);add(bo);setLayo

13、ut(new FlowLayout();b1.addActionListener(this);b2.addActionListener(this);setBounds(0,0,350,200);setVisible(true);this.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e) if(e.getSource()=b1)Connection con;Statement

14、 sql;if(t1.getText().equals("")JOptionPane.showMessageDialog(this,"请输如要删除的报警点编号");t1.setText("");return;tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch(ClassNotFoundException e3)trycon=DriverManager.getConnection("jdbc:odbc:fufangbiao","&

15、quot;,"");sql=con.createStatement();ResultSet rs=sql.executeQuery("select * from 报警点信息表 where 报警点编号='"+t1.getText() +"'");if(!rs.next()JOptionPane.showMessageDialog(this,"这个报警点不存在,请重新输入!"); t1.setText("");elsesql.executeUpdate("delete fr

16、om 报警点信息表 where 报警点编号 ='"+t1.getText()+"'");JOptionPane.showMessageDialog(this,"删除成功!"); t1.setText("");catch(Exception e1)JOptionPane.showMessageDialog(this,""); if(e.getSource()=b2)super.setVisible(false);5. 添加界面class tianjia extends Frame imple

17、ments ActionListenerBox bo,bo1,bo2;Button b1,b2;JTextField t1,t2,t3,t4,t5,t6;tianjia()super("添加火灾报警点");t1=new JTextField(15);t2=new JTextField(15);t3=new JTextField(15);t4=new JTextField(15);t5=new JTextField(15);t6=new JTextField(15);b1=new Button("确定");b2=new Button("返回&qu

18、ot;);bo1=Box.createVerticalBox();bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点编号");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点名称");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点详细地址");bo1.add(Box.createVerticalStrut(40);bo1.add(ne

19、w Label("报警点隶属单位");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点X坐标");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点Y坐标");bo1.add(Box.createVerticalStrut(40);bo1.add(b1);bo2=Box.createVerticalBox();bo2.add(Box.createVerticalStrut(40);bo2.add(t1)

20、;bo2.add(Box.createVerticalStrut(40);bo2.add(t2);bo2.add(Box.createVerticalStrut(40);bo2.add(t3);bo2.add(Box.createVerticalStrut(40);bo2.add(t4);bo2.add(Box.createVerticalStrut(40);bo2.add(t5);bo2.add(Box.createVerticalStrut(40);bo2.add(t6);bo2.add(Box.createVerticalStrut(40);bo2.add(b2);bo=Box.crea

21、teHorizontalBox();bo.add(bo1);bo.add(Box.createHorizontalStrut(20);bo.add(bo2);bo.add(Box.createHorizontalStrut(20);add(bo);setLayout(new FlowLayout();b1.addActionListener(this);b2.addActionListener(this);setBounds(0,0,350,500);setVisible(true);this.addWindowListener(new WindowAdapter()public void w

22、indowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=b1)Connection con;Statement sql;ResultSet rs;if(t1.getText().equals("")|t2.getText().equals("")|t3.getText().equals("")|t4.getText().equals("")|t5.getText().

23、equals("")|t6.getText().equals("")JOptionPane.showMessageDialog(this,"请输入完整的报警点信息");t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");t6.setText("");return;tryClass.forName("sun.jd

24、bc.odbc.JdbcOdbcDriver");catch(ClassNotFoundException e3)trycon=DriverManager.getConnection("jdbc:odbc:fufangbiao","","");sql=con.createStatement();ResultSet rt=sql.executeQuery("select * from 报警点信息表 where 报警点编号='"+t1.getText() +"'");if(

25、rt.next()JOptionPane.showMessageDialog(this,"有这个报警点编号,请重新输入!"); t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");t6.setText("");elsesql.executeUpdate("insert into 报警点信息表 values('"+t1.getText

26、()+"','" + t2.getText()+"','" + t3.getText() +"','" + t4.getText()+"','" + t5.getText()+"','" + t6.getText()+"')");JOptionPane.showMessageDialog(this,"添加成功!"); t1.setText("");t

27、2.setText("");t3.setText("");t4.setText("");t5.setText("");t6.setText("");catch (Exception e3) e3.printStackTrace(); if(e.getSource()=b2)super.setVisible(false);6. 模拟界面class MoNi extends Frame implements ActionListenerBox bo,bo1,bo2;Button b1,b2;JTex

28、tField t1;File musicFile;URI uri;URL url;AudioClip clip;String s="1.au",;MoNi()super("模拟火灾报警");t1=new JTextField(15);b1=new Button("确定");b2=new Button("返回");bo1=Box.createVerticalBox();bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点编号");bo

29、1.add(Box.createVerticalStrut(40);bo1.add(b1);bo2=Box.createVerticalBox();bo2.add(Box.createVerticalStrut(40);bo2.add(t1);bo2.add(Box.createVerticalStrut(40);bo2.add(b2);bo=Box.createHorizontalBox();bo.add(bo1);bo.add(Box.createHorizontalStrut(20);bo.add(bo2);bo.add(Box.createHorizontalStrut(20);add

30、(bo);setLayout(new FlowLayout();b1.addActionListener(this);b2.addActionListener(this);setBounds(0,0,350,200);setVisible(true);this.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=b1)Connection co

31、n;Statement sql;ResultSet rs;if(t1.getText().equals("")JOptionPane.showMessageDialog(this,"请输入报警点编号");t1.setText("");return;tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch(ClassNotFoundException e3)trycon=DriverManager.getConnection("jdbc:odbc:fufa

32、ngbiao","","");sql=con.createStatement();ResultSet ra=sql.executeQuery("select * from 报警点信息表 where 报警点编号='"+t1.getText() +"'");if(!ra.next()JOptionPane.showMessageDialog(this,"这个报警点不存在,请重新输入:"); t1.setText("");elseint x1=Intege

33、r.parseInt(ra.getString(5).trim();int x2=Integer.parseInt(ra.getString(6).trim();A frame = new A(x1,x2); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(600, 450); frame.setLocationRelativeTo( null ); frame.setVisible(true); System.out.println("yes");musicFile=new File(

34、s0);uri=musicFile.toURI();tryurl=uri.toURL();catch(Exception exp)clip=Applet.newAudioClip(url);clip.play(); catch(Exception e1)JOptionPane.showMessageDialog(this,"asd"); if(e.getSource()=b2)super.setVisible(false);clip.stop();四调试分析1.开始不知道如何实现在地图上的动态显示报警图片,后来通过查资料知道了如下实现2.在运行时遇到了程序无法显示图片的情况

35、,总是抛出异常。五、用户手册 本程序的运行环境为Windows操作系统,eclipse软件。 点击进入系统后,会出现添加报警点,删除报警点,火灾报警模拟等功能。3.如果用户想要退出程序,直接点击运行界面的右上角上的关闭按钮即可,操作很方便。六、测试数据1.开始界面:2. 点击进入后3. 点击添加按钮4. 点击删除按钮5. 点击模拟按钮6. 模拟的界面七、附录 源程序文件清单: Main.javaZhuJieMian.javaGongNengJieMian.javaTianJian.javaShanChu.javaMoNi.javaA. JavaDBConenct.java 源程序 Main.j

36、ava/文件代码如下package 火灾;public class Mainpublic static void main(String args) new ZhuJieMian();ZhuJieMian.java/文件代码如下package 火灾;import java.awt.Button;import java.awt.Frame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.*;import java.awt.event.*;import javax.swin

37、g.*;import javax.swing.border.*;public class ZhuJieMian extends Frame implements ActionListener /* * */private static final long serialVersionUID = 1L;Buttonb1,b2;Label l1;Box bo,bo1;Panel p,p1;ZhuJieMian()super("主界面");b1=new Button("进入系统");b2=new Button("退出系统");l1=new

38、Label("欢迎进入火灾报警模拟系统");p=new Panel();p1=new Panel();l1.setAlignment(Label.CENTER);l1.setFont(new Font("Serif",Font.PLAIN,40);l1.setForeground(Color.red);b1.setForeground(Color.red);b2.setForeground(Color.red);b1.setFont(new Font("Serif",Font.PLAIN,20);b2.setFont(new Font

39、("Serif",Font.PLAIN,20);bo1=Box.createVerticalBox();bo1.add(Box.createVerticalStrut(50);bo1.add(l1);bo1.add(Box.createVerticalStrut(10);p1.add(bo1);bo=Box.createVerticalBox();bo.add(b1);bo.add(Box.createVerticalStrut(20);bo.add(b2);bo.add(Box.createVerticalStrut(50);p.add(bo);add(p1,Border

40、Layout.NORTH);add(p,BorderLayout.SOUTH);b1.addActionListener(this);b2.addActionListener(this);setBounds(0,0,600,400);setVisible(true);this.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=b1)new G

41、ongNengJieMian();if(e.getSource()=b2)super.setVisible(false);GongNengJieMian.java/文件代码如下package 火灾;import java.awt.Frame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.*;import java.awt.even

42、t.*;import javax.swing.*;import javax.swing.border.*;class GongNengJieMian extends Frame implements ActionListener Button b1,b2,b3,b4;Box b;GongNengJieMian()super("功能选择界面");b1=new Button(" 添加火灾报警点 ");b2=new Button(" 删除火灾报警点 ");b3=new Button(" 火灾报警模拟");b4=new B

43、utton(" 退出 ");b=Box.createVerticalBox();b.add(Box.createVerticalStrut(40);b.add(b1);b.add(Box.createVerticalStrut(40);b.add(b2);b.add(Box.createVerticalStrut(40);b.add(b3);b.add(Box.createVerticalStrut(40);b.add(b4);add(b);b1.addActionListener(this);b2.addActionListener(this);b3.addActionL

44、istener(this);b4.addActionListener(this);setLayout(new FlowLayout();setBounds(0,0,300,400);setVisible(true);validate();this.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=b1)new tianjia();if(e.g

45、etSource()=b2)new ShanChu();if(e.getSource()=b3)new MoNi();if(e.getSource()=b4)super.setVisible(false);TianJian.java/文件代码如下package 火灾;import java.awt.Frame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;imp

46、ort javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;class tianjia extends Frame implements ActionListenerBox bo,bo1,bo2;Button b1,b2;JTextField t1,t2,t3,t4,t5,t6;tianjia()super("添加火灾报警点");t1=new JTextField(15);t2=new JTextField(15);t3=new JTextField(15);t4=new JTe

47、xtField(15);t5=new JTextField(15);t6=new JTextField(15);b1=new Button("确定");b2=new Button("返回");bo1=Box.createVerticalBox();bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点编号");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点名称");bo1.add(Bo

48、x.createVerticalStrut(40);bo1.add(new Label("报警点详细地址");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点隶属单位");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点X坐标");bo1.add(Box.createVerticalStrut(40);bo1.add(new Label("报警点Y坐标");bo1.add(Box.

49、createVerticalStrut(40);bo1.add(b1);bo2=Box.createVerticalBox();bo2.add(Box.createVerticalStrut(40);bo2.add(t1);bo2.add(Box.createVerticalStrut(40);bo2.add(t2);bo2.add(Box.createVerticalStrut(40);bo2.add(t3);bo2.add(Box.createVerticalStrut(40);bo2.add(t4);bo2.add(Box.createVerticalStrut(40);bo2.add(

50、t5);bo2.add(Box.createVerticalStrut(40);bo2.add(t6);bo2.add(Box.createVerticalStrut(40);bo2.add(b2);bo=Box.createHorizontalBox();bo.add(bo1);bo.add(Box.createHorizontalStrut(20);bo.add(bo2);bo.add(Box.createHorizontalStrut(20);add(bo);setLayout(new FlowLayout();b1.addActionListener(this);b2.addActio

51、nListener(this);setBounds(0,0,350,500);setVisible(true);this.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=b1)Connection con;Statement sql;ResultSet rs;if(t1.getText().equals("")|t2.g

52、etText().equals("")|t3.getText().equals("")|t4.getText().equals("")|t5.getText().equals("")|t6.getText().equals("")JOptionPane.showMessageDialog(this,"请输入完整的报警点信息");t1.setText("");t2.setText("");t3.setText("");

53、t4.setText("");t5.setText("");t6.setText("");return;tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch(ClassNotFoundException e3)trycon=DriverManager.getConnection("jdbc:odbc:fufangbiao","","");sql=con.createStatement();ResultSet rt=sql.executeQuery(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论