




已阅读5页,还剩31页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
目录一、需求分析2二、概要设计2三、详细设计3四、调试分析15五、用户手册15六、测试数据15七、附录18一、需求分析编写一个模拟火灾报警的系统,要求能够做到完成报警编号的录入,删除,修改,查询,删除功能,在某个地点按下报警,会显示出该地点的报警,并有报警声音。程序执行的命令:1. 进入系统的登录界面2. 进入系统后的界面选择3. 实现报警二、概要设计1. 功能模块图:火灾报警管理系统 报警模拟报警点的删除报警点的录入 2. 构程序中所使用的数据结构的介绍class GongNengJieMian extends Frame implements ActionListener /实现登录的主界面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/模拟报警的程序模块public 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;/设置容器的大小Buttonb1,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.setForeground(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(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.addWindowListener(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 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);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.addWindowListener(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 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.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(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 con;Statement 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,);sql=con.createStatement();ResultSet rs=sql.executeQuery(select * from 报警点信息表 where 报警点编号=+t1.getText() +);if(!rs.next()JOptionPane.showMessageDialog(this,这个报警点不存在,请重新输入!); t1.setText();elsesql.executeUpdate(delete from 报警点信息表 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 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 JTextField(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(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(报警点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);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.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.addActionListener(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.getText().equals()|t3.getText().equals()|t4.getText().equals()|t5.getText().equals()|t6.getText().equals()JOptionPane.showMessageDialog(this,请输入完整的报警点信息);t1.setText();t2.setText();t3.setText();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(select * from 报警点信息表 where 报警点编号=+t1.getText() +);if(rt.next()JOptionPane.showMessageDialog(this,有这个报警点编号,请重新输入!); t1.setText();t2.setText();t3.setText();t4.setText();t5.setText();t6.setText();elsesql.executeUpdate(insert into 报警点信息表 values(+t1.getText()+, + t2.getText()+, + t3.getText() +, + t4.getText()+, + t5.getText()+, + t6.getText()+);JOptionPane.showMessageDialog(this,添加成功!); t1.setText();t2.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;JTextField 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(报警点编号);bo1.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(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 con;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:fufangbiao,);sql=con.createStatement();ResultSet ra=sql.executeQuery(select * from 报警点信息表 where 报警点编号=+t1.getText() +);if(!ra.next()JOptionPane.showMessageDialog(this,这个报警点不存在,请重新输入:); t1.setText();elseint x1=Integer.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(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.在运行时遇到了程序无法显示图片的情况,总是抛出异常。五、用户手册 本程序的运行环境为Windows操作系统,eclipse软件。 点击进入系统后,会出现添加报警点,删除报警点,火灾报警模拟等功能。3.如果用户想要退出程序,直接点击运行界面的右上角上的关闭按钮即可,操作很方便。六、测试数据1.开始界面:2. 点击进入后3. 点击添加按钮4. 点击删除按钮5. 点击模拟按钮6. 模拟的界面七、附录 源程序文件清单: Main.javaZhuJieMian.javaGongNengJieMian.javaTianJian.javaShanChu.javaMoNi.javaA. JavaDBConenct.java 源程序 Main.java/文件代码如下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.swing.*;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 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(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,BorderLayout.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 GongNengJieMian();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.event.*;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 Button( 退出 );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.addActionListener(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.getSource()=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;import 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 JTextField(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(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(报警点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);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.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.addActionListener(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.getText().equals()|t3.getText().equals()|t4.getText().equals()|t5.getText().equals()|t6.getText().equals()JOptionPane.showMessageDialog(this,请输入完整的报警点信息);t1.setText();t2.setText();t3.setText();t4.setText();t5.setText();t6.setText();return;tryClass.forN
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 红酒生意基础知识培训课件
- 2025年艺人经纪合同范本:主播艺人签约协议(律师专业风险评估与批注)
- 红楼梦翻译对比课件
- 资源型城市绿色转型发展模式与绿色产业国际合作2025年研究
- 娱乐活动组织与安全保障协议
- 2025年太阳能光伏电站安全生产标准化改造案例集
- 2025年新能源汽车充电服务市场技术创新与充电设备创新研究报告
- 新能源汽车行业2026年市场深度解析:技术创新驱动310亿美元市场规模
- 2025年后视提篮镜行业研究报告及未来行业发展趋势预测
- 2025年社会工作者职业资格考试(社会工作实务初级)冲刺模拟试题及答案
- DB61∕T 1576-2022 矩形钢管混凝土组合桁梁桥技术规范
- 2025-2026学年人教版(2024)初中生物八年级上册(全册)教学设计(附目录)
- 2025-2030中国汽车工程服务外包(ESO)行业现状调查与前景趋势研究报告
- 职业中学数学课件学习方法
- 2025年中国药用菌行业投资前景及策略咨询研究报告
- 软陶教学课件
- 2025年黑吉辽蒙高考化学试卷真题解读及答案详解(精校打印)
- 美术教育学新编
- TCDSA 201.22-2024 呼吸气体质量分析仪
- 特种设备重大事故隐患判定准则试题及答案
- 二年级语文(统编版)二年级上册学习导引课课件
评论
0/150
提交评论