~我自己写了一部分~其他写不下去了
一.基本要求:
1>.100以内的,+,-,*,/,(/必须为整除) 1-100
2>.一共有25题,一道题4分.
3>.可以选择退出(0分),放弃若干单个题目.
4>.做完所有题目的时候,统计结果.放弃个数,答对个数,答错个数,总分数.学号,姓名 .
5>.登陆框. 学号,密码.提供集合来管理所有的学生.
二.基本界面:
用户登陆:
(1)清除按钮清空文本框
(2) 注册按钮进入用户注册
(3)退出按钮请用户最后确认
(4)注册登陆之后进入考试系统
我自己写了一个登陆的框,是用卡式结构写的,其他有点写不下去了~这个登陆框也只打了个架子,里面的事件处理就不会写了~这个程序应该还有个Student.java和Manage.java~谁能帮我一下
package com.homework4;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Land implements ActionListener
{
private JFrame frame;
private Container contentPane;
private JTextField userText;
private JPasswordField pwdText;
private JButton newBtn,clearBtn,okBtn,exitBtn;
private JTextField userTextN;
private JTextField pwdTextN,pwdTextRN;
private JButton clearBtnN,okBtnN,exitBtnN;
private Manage manage;
public Land()
{
frame=new JFrame("用户登陆");
frame.setBounds(350,250,300,170);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane=frame.getContentPane();
manage=Manage.getManage();
initGUI();
}
public void initGUI()
{
contentPane.setLayout(new CardLayout());
contentPane.add(getPanel(0),"");
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==userText)
{
if(userText.getText().trim().length()==0)
userText.grabFocus();
else
pwdText.grabFocus();
}
if(e.getSource()==pwdText||e.getSource()==okBtn)
{
}
if(e.getSource()==clearBtn)
{
userText.setText("");
pwdText.setText("");
userText.grabFocus();
}
if(e.getSource()==newBtn)
{
selectPanel(1);
}
if(e.getSource()==exitBtn)
{}
}
public void selectPanel(int id)
{
CardLayout c=(CardLayout)contentPane.getLayout();
contentPane.add(getPanel(id),"");
c.next(contentPane);
}
public JPanel getPanel(int id)
{
JPanel pAll=null;
switch(id)
{
case 0:
{
userText=new JTextField(10);
JPanel p1=new JPanel(new FlowLayout());
p1.add(new JLabel("用户名: "));
p1.add(userText);
pwdText=new JPasswordField(10);
JPanel p2=new JPanel(new FlowLayout());
p2.add(new JLabel("密 码: "));
p2.add(pwdText);
JPanel p=new JPanel(new GridLayout(2,1));
p.add(p1);
p.add(p2);
clearBtn=new JButton("清除");
newBtn=new JButton("注册");
okBtn=new JButton("确定");
exitBtn=new JButton("退出");
JPanel p3=new JPanel(new FlowLayout());
p3.add(clearBtn);
p3.add(newBtn);
p3.add(okBtn);
p3.add(exitBtn);
pAll=new JPanel(new BorderLayout());
pAll.add(p,BorderLayout.CENTER);
pAll.add(p3,BorderLayout.SOUTH);
userText.addActionListener(this);
pwdText.addActionListener(this);
clearBtn.addActionListener(this);
newBtn.addActionListener(this);
okBtn.addActionListener(this);
exitBtn.addActionListener(this);
}break;
case 1:
{
userTextN=new JTextField(10);
JPanel p1=new JPanel(new FlowLayout());
p1.add(new JLabel("用 户 名: "));
p1.add(userTextN);
pwdTextN=new JTextField(10);
JPanel p2=new JPanel(new FlowLayout());
p2.add(new JLabel("密 码: "));
p2.add(pwdTextN);
pwdTextRN=new JTextField(10);
JPanel p3=new JPanel(new FlowLayout());
p3.add(new JLabel("再次输入: "));
p3.add(pwdTextRN);
JPanel p=new JPanel(new GridLayout(3,1));
p.add(p1);
p.add(p2);
p.add(p3);
clearBtnN=new JButton("清除");
okBtnN=new JButton("确定");
exitBtnN=new JButton("退出");
JPanel p4=new JPanel(new FlowLayout());
p4.add(clearBtnN);
p4.add(okBtnN);
p4.add(exitBtnN);
pAll=new JPanel(new BorderLayout());
pAll.add(p,BorderLayout.CENTER);
pAll.add(p4,BorderLayout.SOUTH);
}break;
case 2:
{}break;
}
return pAll;
}
public void go()
{
frame.setVisible(true);
}
public static void main(String args[])
{
(new Land()).go();
}
}
----------------解决方案--------------------------------------------------------
是要连接数据库的吧,偶还没用到。。。
----------------解决方案--------------------------------------------------------
值得做一做!
----------------解决方案--------------------------------------------------------