ImageVerifierCode 换一换
格式:DOCX , 页数:25 ,大小:325.74KB ,
资源ID:1064044      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-1064044.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(投票管理系统Word下载.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

投票管理系统Word下载.docx

1、 private int id; /候选者的编号 private int num; / 得票数量 private double voteResult; /得票率 private boolean isVote; /是否中选 Candidate(String name, int id) ;/Candidate 的构造方法 public String getName() ;public void setName(String name) ; public int getId() ; public void setId(int id) ; public int getNum() ; public vo

2、id setNum(int num) ; public double getVoteResult() ; public void setVoteResult(double voteResult) ; public boolean isVote(); public void setVote(boolean isVote) ;2.2.2、管理类:Manager类public class Manager public int candidates; / 候选人的数量 public int percentage; / 当选标准(百分比) public int voters = 0; / 投票人数量 L

3、ist listc ;/ 装载候选者的容器 public static void main(String args) ; public void calculateResult() ;/ 计算结果 2.2.3、窗口的操作类UserInterface public class UserInterface extends JFrame private static final long serialVersionUID = 1L; public Container contentPanel; / 当前界面控制器 public Manager manager; /利于数据通信,主要包括:候选人数量、

4、当选标准、投票者数量 public JPanel p1; /输入信息的面板 public JPanel p2; /投票面板 public JPanel p3; /显示投票结果的面板 public List list_textfield ;/装载候选人姓名的容器JRadioButton list_jradiobutton ;/投票 public UserInterface(Manager m) ; public void update() ;/窗口中增删组建后立即更新 public void addCandi(int num);/panel1输入侯选者姓名完成后,生成候选者对象 2.2.4、输入

5、面板类:MainGraphpublic class MainGraph private UserInterface userInterface; /与主面板的通信 public MainGraph(UserInterface userInterface) ;/MainGraph的构造函数 public void launchMainGraph() ;/加载主面板2.2.5、投票面板类:VoteGraph public class VoteGraph /与主面板的通信 public VoteGraph(UserInterface userInterface) ;/构造函数 public void

6、 launchVoteGraph();/加载投票面板2.2.6、显示结果类:ResultGraphpublic class ResultGraph public ResultGraph(UserInterface userInterface) ;/构造函数 public void launchResultGraph() ;/加载显示结果的面板3 功能实现 3.1 窗口显示点击运行后弹出一个窗口(Panel1),要求用户输入候选人的个数(1-12)以及当选标准(若为50%,只需输入50即可) 假若依次输入12, 50.点击确定后,窗口中会提示输入侯选人的姓名,候选人的编号是从小到大依次生成的。

7、依次输入12人的姓名点击提交后,就会弹出投票的窗口假若共有7名投票人参与投票(每次投票完点击提交即为完成依次投票)投票过程如下:投票者1:1号:吴红岩 3号:邵芳 9号:李丹 11号:李四投票者2: 2号:刘莉莉 3号:邵芳 4号:尹聪敏 6号:王小丽 8号:王永霞 投票者3: 1号:吴红岩 2号:刘莉莉 4号:尹聪敏 5号:张三 7号:李泽 9号:李丹投票者4:吴红岩 7号:李泽 12号:王龙贺 投票者5: 3号:张三 7号:李泽10号:王小慧投票者6: 10号:王小慧 11号:李四 12号:王龙贺投票者7:尹聪敏 最终的投票结果如下图所示: 3.2 功能1 整个系统的UML时序图如下图所示

8、:附录:程序源代码1、Candidate 的详细代码: Candidate(String name, int id) this.name = name; this.id = id; this.num = 0; this.voteResult = 0; this.isVote = false; public String getName() return name; public void setName(String name) public int getId() return id; public void setId(int id) public int getNum() return

9、num; public void setNum(int num) this.num = num; public double getVoteResult() return voteResult; public void setVoteResult(double voteResult) this.voteResult = voteResult; public boolean isVote() return isVote; public void setVote(boolean isVote) this.isVote = isVote; public String toString() retur

10、n this.name;2、Manager类的详细代码import java.util.ArrayList;import java.util.List; listc = new ArrayList(); public static void main(String args) Manager m = new Manager(); UserInterface ui = new UserInterface(m); MainGraph mainGraph = new MainGraph(ui); mainGraph.launchMainGraph(); public void calculateRe

11、sult() double d; for (int i = 0; i = percentage * 0.01) c.setVote(true); 3、UserInterface类的详细代码:import java.awt.Color;import java.awt.Container;import java.awt.Font;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Iterator;import java.util.Vector;import javax.sw

12、ing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.SwingConstants;import javax.swing.table.DefaultTableCellRenderer;/* * *

13、author why * */ list_textfield = new ArrayList list_jradiobutton = new ArrayList= this.getHeight() - 250) y = yy; x1 = x1 + 300; x2 = x2 + 300; y += 50; text_name = new JTextField(); / 新建输入姓名的文本框 label_name = new JLabel(ss); label_name.setText(候选人 + i + 的姓名: label_name.setBounds(x1, y, w, h); text_n

14、ame.setBounds(x2, y, w, h); list_textfield.add(text_name); / 把输入姓名的文本框加入到list中 p1.add(label_name); p1.add(text_name); this.update(); submit.setBounds(this.getWidth() / 3, this.getHeight() - 150, 100, 20); submit.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) for (i

15、nt i = 0; list_textfield.size(); String name = list_textfield.get(i).getText(); / 得到文本框中输入的候选者姓名 Candidate candi = new Candidate(name, i + 1); / 根据输入的姓名生成一个候选者 manager.listc.add(candi); / 把候选者加入到list中 VoteGraph voteGraph = new VoteGraph(UserInterface.this); voteGraph.launchVoteGraph(); / 加载投票面板(Pane

16、l2) ); p1.add(submit); 4、MainGraph类的详细代码:import java.awt.HeadlessException; * 系统的主界面,接受候选者人数,以及当选的标准 public MainGraph(UserInterface userInterface) super(); this.userInterface = userInterface; public void launchMainGraph() userInterface.p1 = new JPanel(); userInterface.p1.setLayout(null); userInterfa

17、ce.p1.setBackground(Color.orange); userInterface.contentPanel.add(userInterface.p1); JLabel lab = new JLabel(请输入投票信息 lab.setBounds(200, 30, 250, 50); int size = 25; lab.setFont(new Font(Serif, Font.PLAIN, size); JLabel label = new JLabel(请输入候选人的个数(1-12): final JTextField text = new JTextField(); / 输

18、入候选人的个数 JLabel labelp = new JLabel(请输当选标准(百分比): final JTextField pertage = new JTextField(); / 输入当选百分比 JButton b = new JButton(确定 / 对候选人个数与百分比进行计较的按钮 label.setBounds(80, 100, 170, 20); labelp.setBounds(80, 130, 150, 20); text.setBounds(240, 100, 150, 20); pertage.setBounds(240, 130, 150, 20); b.setB

19、ounds(500, 130, 70, 20); b.addActionListener(new ActionListener() userInterface.manager.candidates = Integer.parseInt(text.getText(); / 得到候选者的个数 userInterface.addCandi(userInterface.manager.candidates); userInterface.manager.percentage = Integer.parseInt(pertage.getText(); / 得到当选百分比 userInterface.p1.add(label); userInterface.p1.add(lab); userInterface.p1.add(text); userInterface.p1.add(b); userInterface.p1.add(labelp); userInterface.p1.add(pertage); userInterface.update();5、VoteGraph类的详细代码:public class VoteGraph public VoteGraph(UserInterface userInterface) this.userInterf

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2