资源简介
1.采用单链表存放选票,候选人编号依次为1,2,3,…,N,且每张选票选且只选一人;
2.选票中每个候选人采用一个节点实现,节点中包含一个BOOL变量,表示该候选人是否选上;
3.设计用户输入选票提示信息,并且能够发现输入选票信息是否合法,即选票是否为空,或者是否多选了候选人;
4.统计各位候选人的得票情况;
5.对程序进行扩展,假定选票中允许选民可以最多可以选三人,设计选票统计系统。
请按照代码中使用文档的路径存放文件夹即可正常使用

代码片段和文件信息
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
public class AdministorAddUser extends Jframe implements ActionListener {
private JPanel contentPane;
private JTextField nametextField;
public UserData people = new UserData();
private int count=1;
public AdministorAddUser() throws ClassNotFoundException {
this.setBounds(100 100 505 371);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5 5 5 5));
setContentPane(contentPane);
contentPane.setLayout(null);
Image icon = Toolkit.getDefaultToolkit().getImage(“D:/eclips/Voting System2/icon.jpg“);
this.setIconImage(icon);
ImageIcon img=new ImageIcon(“D:/eclips/Voting System2/Background.jpg“);
JLabel imglabel=new JLabel(img);
contentPane.setOpaque(false);
getlayeredPane().add(imglabelnew Integer(Integer.MIN_VALUE));
imglabel.setBounds(00img.getIconWidth()img.getIconHeight());
((JPanel)getContentPane()).setOpaque(false);
JLabel label=new JLabel(“请输入用户信息!“);
label.setFont(new Font(“华文新魏“Font.BOLD15));
label.setBounds(9010label.getPreferredSize().widthlabel.getPreferredSize().height);
contentPane.add(label);
nametextField = new JTextField();
nametextField.setBounds(40 4020027);
contentPane.add(nametextField);
nametextField.setColumns(40);
JButton confirmButton = new JButton(“添加“);
confirmButton.setFont(new Font(“楷体“ Font.BOLD 15));
confirmButton.setBackground(Color.white);
confirmButton.addActionListener(this);
confirmButton.setBounds(160100confirmButton.getPreferredSize().width confirmButton.getPreferredSize().height);
contentPane.add(confirmButton);
JButton backButton = new JButton(“返回“);
backButton.setFont(new Font(“楷体“Font.BOLD15));
backButton.setBackground(Color.white);
backButton.setBounds(60100backButton.getPreferredSize().widthbackButton.getPreferredSize().height);
contentPane.add(backButton);
backButton.addActionListener(this);
this.setVisible(true);
this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
this.setSize(300 200);
this.setLocationRelativeTo(null);//窗体居中显示
this.settitle(“Add“);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (e.getActionCommand()==“添加“) {
if(nametextField.getText().equals(““)) {
JOptionPane.showMessageDialog(null “输入候选人为空“);
}
else {
people.add(“0“nametextField.getText()“123456“false);
nametextField.setText(““);
}
}
if (e.getActionCommand()==“返回“) {
try {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 301 2018-12-12 22:25 Voting System2\.classpath
文件 390 2018-12-12 22:25 Voting System2\.project
文件 598 2018-12-12 22:25 Voting System2\.settings\org.eclipse.jdt.core.prefs
文件 55217 2018-12-23 21:04 Voting System2\32.gif
文件 58364 2018-12-19 23:51 Voting System2\Background.jpg
文件 62660 2018-12-20 21:17 Voting System2\Background1.jpg
文件 4184 2018-12-27 11:42 Voting System2\bin\AdministorAddUser.class
文件 5922 2018-12-27 14:25 Voting System2\bin\AdministorFunction.class
文件 4598 2018-12-27 11:42 Voting System2\bin\AdministorLogin.class
文件 775 2018-12-27 11:42 Voting System2\bin\AdministorSetVote$1.class
文件 1197 2018-12-27 11:42 Voting System2\bin\AdministorSetVote$2.class
文件 1200 2018-12-27 11:42 Voting System2\bin\AdministorSetVote$3.class
文件 1054 2018-12-27 11:42 Voting System2\bin\AdministorSetVote$4.class
文件 7215 2018-12-27 11:42 Voting System2\bin\AdministorSetVote.class
文件 646 2018-12-27 11:42 Voting System2\bin\AdministorSingle_Add$1.class
文件 4404 2018-12-27 11:42 Voting System2\bin\AdministorSingle_Add.class
文件 4890 2018-12-27 11:42 Voting System2\bin\AdministorUser.class
文件 2301 2018-12-27 11:42 Voting System2\bin\AdministorViewUser$1.class
文件 3832 2018-12-27 11:42 Voting System2\bin\AdministorViewUser.class
文件 1921 2018-12-27 12:44 Voting System2\bin\AdministorViewVoteReult$1.class
文件 890 2018-12-27 12:44 Voting System2\bin\AdministorViewVoteReult$2.class
文件 4321 2018-12-27 12:44 Voting System2\bin\AdministorViewVoteReult.class
文件 4542 2018-12-27 12:45 Voting System2\bin\li
文件 6934 2018-12-27 12:45 Voting System2\bin\li
文件 890 2018-12-27 11:42 Voting System2\bin\Login$1.class
文件 896 2018-12-27 11:42 Voting System2\bin\Login$2.class
文件 567 2018-12-27 11:42 Voting System2\bin\Login$3.class
文件 567 2018-12-27 11:42 Voting System2\bin\Login$4.class
文件 4943 2018-12-27 11:42 Voting System2\bin\Login.class
文件 3352 2018-12-27 12:38 Voting System2\bin\sortli
............此处省略41个文件信息
- 上一篇:爬虫jsp获取网页源码
- 下一篇:Mateix3x3f.java矩阵的Java实现
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
评论
共有 条评论