1、山东建筑大学计算机科学与技术学院程序设计实用案例选讲大作业说明书题 目: 房地产中介管理系统课 程: 程序设计实用案例选讲 院 (部): 计算机科学与技术专 业: 网络工程班 级: 网络131学生姓名: 高雷学 号: 20131113033指导教师: 袁卫华完成日期: 2014/01/08山东建筑大学计算机学院大作业设计说明书目 录房地产中介管理系统1一、问题描述1二、设计思想1三、系统结构1四、程序流程(或模块划分)2五、源程序3六、系统测试及操作界面22结论30参考文献31I山东建筑大学计算机学院大作业设计说明书房地产中介管理系统一、问题描述某房屋中介公司主要的业务包括房屋出租和二手房买卖
2、,请编程实现“房屋中介管理系统”,具体要求如下:一、房源基本信息管理,(房屋编号,户型(如两室一厅,三室两厅),具体地址(坐落位置),建造年月,状态(待售,待出租,已售,已出租等),价格(租金/月或售价),房主姓名,联系方式等),请编程实现这些基本信息的增、删、改、查等操作.二、房屋出租操作,对于所有“待出租”状态的房屋,可以执行出租操作,其状态转换为“已出租,根据出租的月数,计算租金,并征收中介费(中介费一般等于一个月的租金);处于“已出租”状态的房屋不能执行该操作。三、 房屋出售操作,对于所有“待出售”状态的房屋,可以执行出手操作,其状态转换为“已售”,根据房价和中介费计算方法(自己查),
3、计算应该征收的中介费二、设计思想此管理系统主要实现对房源的增删改查四个主要功能,以及将数据输出保存文件。本系统分为管理员和普通用户两个类别用户,管理员可以对房源信息的增删改查等操作,普通用户无法更改信息,可以查询信息.另外,针对大量的用户,可以注册新的用户。管理员在添加新的房源信息时需要确保输入每一个信息,否则会提醒管理员输入完整。修改信息可以修改一个信息,也可以同时修改多个信息,修改成功会依次提示。查询时主要可以通过查询户型以及房屋状态查询。用户查询到需要的房源时通过管理员修改房源信息,并将房屋的状态改变出租或出售给用户.三、 系统结构房地产管理系统包括7个主要类:BuildingSyste
4、m。Java:主操作界面,登录界面、选择用户类型等信息Admin。java管理员登录界面Admin1.java管理员操作界面RegisterException。java用于两次密码不一致时抛异常User.java普通用户登录界面User1.java普通用户操作界面ZhuCe。java新用户注册四、程序流程(或模块划分) 图41 程序流程图五、源程序BuildingStystempackagegaolei;publicclassBuildingSystemimplementsRunnable,ActionListenerJFramef1;JPanelp1, p2,p3,p4;JLabell21;
5、JButtonfunction1, function2, function3, function4;JButtonend;ThreadscollWorsThread;booleanstopScorlling;BuildingSystem() f1 = new JFrame(-房屋中介管理系统-”);p1 = new JPanel();p1。setBackground(Color.white);p1.setLayout(new GridLayout(5, 1, 5, 5);function1 = new JButton( 【管理员登录通道】 );p1.add(function1);functio
6、n1.setBackground(Color。getHSBColor(100, 152, 188));function1。addActionListener(this);function2 = new JButton(”【普通用户登陆通道】);function2.setBackground(Color.getHSBColor(100, 152, 188));p1.add(function2);function2.addActionListener(this);function3 = new JButton( 【新用户注册】 ”);p1。add(function3);function3。setB
7、ackground(Color。getHSBColor(100, 152, 188);function3。addActionListener(this);function4 = new JButton( 【系统信息】 );p1。add(function4);function4.setBackground(Color。getHSBColor(100, 152, 188));function4。addActionListener(this);end = new JButton(” 【 退 出 程 序 】 ”);p1。add(end);end。setBackground(Color。getHSBCo
8、lor(100, 152, 188));end。addActionListener(this);f1。add(BorderLayout。EAST, p1);p2 = new JPanel();p2。setBackground(Color。getHSBColor(100, 10,255));p2。setLayout(new GridLayout(3, 1);JLabelempty1=newJLabel();p2。add(empty1);l21 = new JLabel(” 高雷房地产公司欢迎您O(_)O ”);l21.setForeground(Color。DARK_GRAY);l21。setF
9、ont(new Font(华文行楷”,1,17);p2。add(l21);JLabel empty2 = new JLabel(” ”);p2.add(empty2);f1.add(BorderLayout.NORTH, p2);p3 = new JPanel()private static final long serialVersionUID = 1L;public void paint(Graphics g) ImageIcon icon=new ImageIcon(”F:Java information12.png”); Image image=icon。getImage(); g。d
10、rawImage(image, 0,0, null); ;p3。setBackground(Color.white);JLabel nn = new JLabel(” ”);p3。add(nn);f1.add(BorderLayout。SOUTH, p3);p4 = new JPanel()private static final long serialVersionUID = 1L;public void paint(Graphics g) ImageIcon icon=new ImageIcon(F:Java information12。png”); Image image=icon。ge
11、tImage(); g.drawImage(image, 0,0, null); ;p4。setBackground(Color。white);f1。add(BorderLayout.CENTER, p4);scollWorsThread = new Thread(this);scollWorsThread.start();f1。setResizable(false);f1。setSize(470, 285);f1。setVisible(true);f1。setLocation(400, 180);f1。setDefaultCloseOperation(JFrame。EXIT_ON_CLOSE
12、);public void run() while (true) int x = l21.getBounds()。x;int y = l21。getBounds()。y;x += 5;l21.setLocation(x, y);if (x 420) x = 0;l21。setLocation(x, y);try Thread.sleep(1000); catch (InterruptedException e) if (stopScorlling = true) return;public void actionPerformed(ActionEvent e)try if (e。getSour
13、ce() = function1) new Admin(); else if (e.getSource() = function2) new User(); else if (e。getSource() = function3) new ZhuCe(); else if (e。getSource() = function4) JOptionPane.showMessageDialog(null, this, ”系统简介 ”, 3); else if (e。getSource() = end) System.exit(1); catch (Exception e1) e1。printStackT
14、race();public static void main(String args) throws Exceptionnew BuildingSystem();Adminpackage gaolei;public class BuildingSystem implements Runnable,ActionListener JFrame f1;JPanel p1, p2,p3,p4;JLabel l21;JButton function1, function2, function3, function4;JButton end;Thread scollWorsThread;boolean s
15、topScorlling; BuildingSystem() f1 = new JFrame(”-房屋中介管理系统-”);p1 = new JPanel();p1.setBackground(Color.white);p1。setLayout(new GridLayout(5, 1, 5, 5));function1 = new JButton( 【管理员登录通道】 ”);p1。add(function1);function1。setBackground(Color。getHSBColor(100, 152, 188));function1.addActionListener(this);fu
16、nction2 = new JButton(【普通用户登陆通道】”);function2.setBackground(Color.getHSBColor(100, 152, 188);p1.add(function2);function2。addActionListener(this);function3 = new JButton(” 【新用户注册】 ”);p1。add(function3);function3.setBackground(Color。getHSBColor(100, 152, 188));function3。addActionListener(this);function4
17、 = new JButton(” 【系统信息】 ”);p1。add(function4);function4。setBackground(Color。getHSBColor(100, 152, 188);function4。addActionListener(this);end = new JButton( 【 退 出 程 序 】 ”);p1。add(end);end.setBackground(Color。getHSBColor(100, 152, 188));end。addActionListener(this);f1.add(BorderLayout。EAST, p1);p2 = new
18、 JPanel();p2.setBackground(Color。getHSBColor(100, 10,255));p2。setLayout(new GridLayout(3, 1));JLabel empty1 = new JLabel(” ”);p2。add(empty1);l21 = new JLabel(” 高雷房地产公司欢迎您O(_)O );l21。setForeground(Color.DARK_GRAY);l21.setFont(new Font(”华文行楷,1,17);p2.add(l21);JLabel empty2 = new JLabel(” );p2.add(empt
19、y2);f1。add(BorderLayout.NORTH, p2);p3 = new JPanel()private static final long serialVersionUID = 1L;public void paint(Graphics g) ImageIcon icon=new ImageIcon(F:Java information12。png”); Image image=icon。getImage(); g。drawImage(image, 0,0, null); ;p3。setBackground(Color。white);JLabel nn = new JLabel
20、(” ”);p3。add(nn);f1.add(BorderLayout.SOUTH, p3);p4 = new JPanel()private static final long serialVersionUID = 1L;public void paint(Graphics g) ImageIcon icon=new ImageIcon(F:Java information12.png); Image image=icon。getImage(); g.drawImage(image, 0,0, null); ;p4。setBackground(Color。white);f1。add(Bor
21、derLayout。CENTER, p4)scollWorsThread = new Thread(this);scollWorsThread.start();f1。setResizable(false);f1.setSize(470, 285);f1。setVisible(true);f1。setLocation(400, 180);f1。setDefaultCloseOperation(JFrame。EXIT_ON_CLOSE);public void run() while (true) int x = l21。getBounds()。x;int y = l21.getBounds().
22、y;x += 5;l21.setLocation(x, y);if (x 420) x = 0;l21。setLocation(x, y);try Thread。sleep(1000); catch (InterruptedException e) if (stopScorlling = true) return;public void actionPerformed(ActionEvent e)try if (e。getSource() = function1) new Admin(); else if (e。getSource() = function2) new User(); else
23、 if (e.getSource() = function3) new ZhuCe(); else if (e。getSource() = function4) JOptionPane.showMessageDialog(null, this, ”系统简介 , 3); else if (e。getSource() = end) System。exit(1); catch (Exception e1) e1。printStackTrace();public static void main(String args) throws Exceptionnew BuildingSystem();Adm
24、in1package gaolei;;public class Admin1 extends JFrame implements ActionListenerJFrame f;JLabel jl,j2,j3,j4,j5,j6,j7,j8;JTextField jf1,jf2,jf3,jf4,jf5,jf6,jf7,jf8;JButton jb1,jb2,jb3,jb4,jb5,jb6,jb7,jb8;JPanel jp1;int id;int m=0;JTextArea result;String DBDriver=sun。jdbc.odbc.JdbcOdbcDriver;String con
25、nectionStr=”jdbc:odbc:HouseInfo1”;Statement stmt=null,s1=null;Connection con=null;ResultSet rs=null;PreparedStatement stmt1=null,stmt2=null,stmt3=null,stmt4=null;public Admin1() f = new JFrame(房源基本信息);jp1=new JPanel();jp1。setLayout(new GridLayout(5, 2));jl=new JLabel(”编号:);j2=new JLabel(”房主姓名:);j3=n
26、ew JLabel(”联系方式:”);j4=new JLabel(”坐落位置:);j5=new JLabel(”建造年月:”);j6=new JLabel(价格:”);j7=new JLabel(户型);j8=new JLabel(”房屋状态”);jf1=new JTextField(10);jf2=new JTextField(10);jf3=new JTextField(10);jf4=new JTextField(10);jf5=new JTextField(10);jf6=new JTextField(10);jf7=new JTextField(10);jf8=new JTextFi
27、eld(10);jb1=new JButton(”录入);jb2=new JButton(修改”);jb3=new JButton(”删除);jb4=new JButton(查询”);jp1.add(jl);jp1。add(jf1);jp1。add(j2);jp1。add(jf2);jp1.add(j3);jp1。add(jf3);jp1。add(j4);jp1。add(jf4);jp1。add(j5);jp1.add(jf5);jp1。add(j6);jp1。add(jf6);jp1.add(j7);jp1。add(jf7);jp1.add(j8);jp1.add(jf8);jp1。add(
28、jb1);jp1.add(jb2);jp1。add(jb3);jp1。add(jb4);jb1.addActionListener(this);jb2。addActionListener(this);jb3。addActionListener(this);jb4。addActionListener(this);f。add(BorderLayout。NORTH, jp1);result = new JTextArea(60, 100);result.setEditable(false);JScrollPane jScrollPane=new JScrollPane(result);f.add(B
29、orderLayout。CENTER, jScrollPane);f.setSize(500, 600);f。setLocation(600, 80);f。setVisible(true);f。validate();public void insert()int m=0;tryClass.forName(DBDriver);/加载驱动器表达式catch(ClassNotFoundException e1)e1。printStackTrace();String id=jf1。getText();String name=jf2。getText();String tel=jf3.getText();
30、String loc=jf4。getText();String riqi=jf5。getText();String price=jf6。getText();String type=jf7。getText();String zt=jf8.getText();if(!id.equals()&!name。equals(”)&!tel。equals(”)&!loc.equals()&!riqi。equals(”)&!price.equals(”)&!type。equals(”)!zt。equals())trycon=DriverManager。getConnection(connectionStr,”
31、,”);/建立数据库连接String sql1=”INSERT INTO house(id,name,tel,loc,riqi,price,type,zt) values (?,?,?,?,?,?,?,?)”;PreparedStatement stmt1=con。prepareStatement(sql1);stmt1。setString(1,id);stmt1。setString(2,name);stmt1.setString(3,tel);stmt1。setString(4,loc);stmt1。setString(5,riqi);stmt1。setString(6,price);stm
32、t1.setString(7,type);stmt1。setString(8,zt);stmt1.execute();stmt1。close();con.close();m=1;catch (SQLException e1) e1.printStackTrace();if(m=1)JOptionPane。showMessageDialog(this, ”信息已经成功录入”);if(m=0)JOptionPane.showMessageDialog(this, 您输入的不符合要求”);public void xiugai()tryClass。forName(DBDriver);/加载驱动器表达式
33、catch(ClassNotFoundException e1)e1.printStackTrace();int n=0;String id=jf1。getText();String name=jf2.getText();String tel=jf3。getText();String loc=jf4.getText();String riqi=jf5.getText();String price=jf6。getText();String type=jf7。getText();String zt=jf8。getText();if(!id.equals(”)trycon=DriverManager
34、.getConnection(connectionStr,”,”);/建立数据库连接if(!name.equals(”)String sql2=”Update house set name=? where id=?”;stmt1=con.prepareStatement(sql2);stmt1.setString(2,id);stmt1.setString(1,name);stmt1。execute();JOptionPane。showMessageDialog(this, ”房主姓名已经成功修改”);if(!tel.equals(”))String sql3=Update house set
35、 tel=? where id=?”;stmt1=con。prepareStatement(sql3);stmt1。setString(2,id);stmt1.setString(1,tel);stmt1。execute();stmt1。close();JOptionPane。showMessageDialog(this, 联系方式已经成功修改”);if(!loc。equals(”))String sql3=”Update house set loc=? where id=?”;stmt1=con.prepareStatement(sql3);stmt1.setString(2,id);stm
36、t1。setString(1,loc);stmt1。execute();stmt1.close();JOptionPane。showMessageDialog(this, ”坐落位置已经成功修改”);if(!riqi.equals(”))String sql3=Update house set riqi=? where id=?”;stmt1=con。prepareStatement(sql3);stmt1。setString(2,id);stmt1.setString(1,riqi);stmt1。execute();stmt1.close();JOptionPane。showMessageD
37、ialog(this, 建造日期已经成功修改”);if(!price.equals(”)String sql3=”Update house set price=? where id=?;stmt1=con。prepareStatement(sql3);stmt1.setString(2,id);stmt1。setString(1,price);stmt1。execute();stmt1。close();JOptionPane.showMessageDialog(this, ”价格已经成功修改”);if(!type。equals(”)String sql3=”Update house set t
38、ype=? where id=?”;stmt1=con.prepareStatement(sql3);stmt1。setString(2,id);stmt1。setString(1,type);stmt1。execute();stmt1。close();JOptionPane.showMessageDialog(this, ”户型已经成功修改”);if(!zt.equals())String sql3=Update house set zt=? where id=?”;stmt1=con。prepareStatement(sql3);stmt1。setString(2,id);stmt1。se
39、tString(1,zt);stmt1。execute();stmt1.close();JOptionPane。showMessageDialog(this, 房屋状态已经成功修改”);con。close();n=1;catch (SQLException e1) / TODO Autogenerated catch blocke1。printStackTrace();if(n=0)JOptionPane。showMessageDialog(this, ”您输入的不符合要求”);public void delete()int n=0;tryClass.forName(DBDriver);/加载
40、驱动器表达式catch(ClassNotFoundException e1)e1.printStackTrace();String id=jf1。getText();String name=jf2。getText();String tel=jf3.getText();String loc=jf4。getText();String riqi=jf5。getText();String price=jf6.getText();String type=jf7。getText();String zt=jf8.getText();if(!id。equals(”)|!name.equals(”)|!tel.equals(”)!loc.equals(”)|!riqi。equals(”)|!price.equals(”)!type。equals(”)|!zt.equals(”))trycon=DriverManager.getConnection(connectionStr,”);/建立数据库连接String sql2=”delete from house where id=?;stmt1=con。prepareStatement(sql2);stmt1.setString(1,id);stmt1。exe