全国小学四则运算1.0

程序:全国小学四则运算1.0

源代码:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//一开始的界面
public class Menu extends JFrame implements ActionListener{
    JButton enter;
    public Menu()
    {
        super("小学生四则运算大考验");
        setIconImage(Toolkit.getDefaultToolkit().getImage(Menu.class.getResource("/img/33.jpg")));
        this.setSize(578, 516);
        this.setLocation(350, 50);//主窗口位置
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setResizable(true);
        
        ImageIcon img=new ImageIcon(this.getClass().getResource("img/enterimg.png"));

        enter = new JButton("New button");
        enter.setIcon(img);
        getContentPane().add(enter, BorderLayout.CENTER);
        enter.addActionListener(this);
        this.setVisible(true);
    }

    public static void main(String[] args)
    {
        new Menu();
    }

    @Override
    public void actionPerformed(ActionEvent e) 
    {
        if(e.getSource()==enter)
        {
            this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            this.setVisible(false);
            Question question=new Question();
        }
    }
}
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.LineBorder;

import java.awt.*;
import java.math.*;
import java.text.*;
import java.util.regex.Pattern;
//输入题量的对话框 ,检查对话框,出题的界面,检查答案是否规范的对话框
public class Question extends JFrame implements ActionListener {
    public static String s[] = new String[5];
    static String tmnum;// 题目个数
    static int n;// 题目数量
    int[] num1 = new int[5];
    static int num2;// 阶乘的数
    static String[] useranser = new String[5];// 用户输入的答案
    static String[] staticanser = new String[5];// 标准答案
    static DecimalFormat decimal = new DecimalFormat("#.##");

    static JTextField[] textField = new JTextField[5];
    static JButton btnNewButton;
    static JButton button;
    static JButton hybutton;
    static JPanel panel;
    static JPanel p1;
    static Question q1;
    static int hycs = 1;
    Pattern pattern = Pattern.compile("[0-9]*");

    Question() {
        super("测试中......");
        setIconImage(Toolkit.getDefaultToolkit().getImage(Question.class.getResource("/img/33.jpg")));
        getContentPane().setBackground(new Color(255, 255, 0));
        setBackground(new Color(255, 255, 255));
        setForeground(new Color(255, 255, 255));
        this.setSize(499, 383);
        this.setLocation(350, 50);// 主窗口位置
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setResizable(true);
        tmnum = JOptionPane.showInputDialog("请输入题目个数(1~5):");
        do {
            
            if (pattern.matcher(tmnum).matches()) {// 如果输入的是数字就执行
                n = Integer.parseInt(tmnum);
                while (n <= 0 || n >= 6) {
                    tmnum = JOptionPane.showInputDialog("输入错误!请重新输入题目个数(1~5):");
                    n = Integer.parseInt(tmnum);
                }
                break;
            } else {
                tmnum = JOptionPane.showInputDialog("输入错误!请重新输入题目个数(1~5):");
            }
        } while (true);

        
        // 输入题目
        JLabel[] tm = new JLabel[5];
        p1 = new JPanel();
        p1.setForeground(new Color(0, 0, 0));
        p1.setBackground(new Color(253, 245, 230));
        getContentPane().add(p1, BorderLayout.CENTER);
        GridBagLayout gbl_p1 = new GridBagLayout();
        gbl_p1.columnWidths = new int[] { 0, 0, 0 };
        gbl_p1.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        gbl_p1.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
        gbl_p1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
        p1.setLayout(gbl_p1);

        Question.timu(n, num1);

        JLabel label_5 = new JLabel("全国高等小学四则运算练习系统1.0");
        label_5.setFont(new Font("仿宋", Font.BOLD, 27));
        GridBagConstraints gbc_label_5 = new GridBagConstraints();
        gbc_label_5.gridwidth = 2;
        gbc_label_5.insets = new Insets(0, 0, 10, 0);
        gbc_label_5.gridx = 0;
        gbc_label_5.gridy = 0;
        p1.add(label_5, gbc_label_5);

        JLabel label = new JLabel(s[0]);// 第一题标签
        label.setBackground(new Color(144, 238, 144));
        label.setFont(new Font("Batang", Font.PLAIN, 24));
        label.setHorizontalAlignment(SwingConstants.LEFT);
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.anchor = GridBagConstraints.SOUTH;
        gbc_label.fill = GridBagConstraints.HORIZONTAL;
        gbc_label.insets = new Insets(0, 20, 20, 0);
        gbc_label.gridx = 0;
        gbc_label.gridy = 1;
        // label
        p1.add(label, gbc_label);

        JLabel label_1 = new JLabel(s[1]);// 第二题标签
        label_1.setFont(new Font("Batang", Font.PLAIN, 24));
        label_1.setHorizontalAlignment(SwingConstants.LEFT);
        GridBagConstraints gbc_label_1 = new GridBagConstraints();
        gbc_label_1.fill = GridBagConstraints.HORIZONTAL;
        gbc_label_1.insets = new Insets(0, 20, 20, 0);
        gbc_label_1.gridx = 0;
        gbc_label_1.gridy = 2;

        p1.add(label_1, gbc_label_1);

        JLabel label_2 = new JLabel(s[2]);// 第三题标签
        label_2.setFont(new Font("Batang", Font.PLAIN, 24));
        label_2.setHorizontalAlignment(SwingConstants.LEFT);
        GridBagConstraints gbc_label_2 = new GridBagConstraints();
        gbc_label_2.fill = GridBagConstraints.HORIZONTAL;
        gbc_label_2.insets = new Insets(0, 20, 20, 0);
        gbc_label_2.gridx = 0;
        gbc_label_2.gridy = 3;

        p1.add(label_2, gbc_label_2);

        JLabel label_3 = new JLabel(s[3]);// 第四题标签
        label_3.setFont(new Font("Batang", Font.PLAIN, 24));
        label_3.setHorizontalAlignment(SwingConstants.LEFT);
        GridBagConstraints gbc_label_3 = new GridBagConstraints();
        gbc_label_3.fill = GridBagConstraints.HORIZONTAL;
        gbc_label_3.insets = new Insets(0, 20, 20, 0);
        gbc_label_3.gridx = 0;
        gbc_label_3.gridy = 4;
        p1.add(label_3, gbc_label_3);

        JLabel label_4 = new JLabel(s[4]);// 第5题标签
        label_4.setFont(new Font("Batang", Font.PLAIN, 24));
        label_4.setHorizontalAlignment(SwingConstants.LEFT);
        GridBagConstraints gbc_label_4 = new GridBagConstraints();
        gbc_label_4.insets = new Insets(0, 20, 20, 0);
        gbc_label_4.fill = GridBagConstraints.HORIZONTAL;
        gbc_label_4.gridx = 0;
        gbc_label_4.gridy = 5;
        p1.add(label_4, gbc_label_4);

        for (int j = 0; j < n; j++) 
        {
            textField[j] = new JTextField(10);
            GridBagConstraints gbc_textField = new GridBagConstraints();
            gbc_textField.anchor = GridBagConstraints.SOUTH;
            gbc_textField.insets = new Insets(0, 0, 20, 10);
            gbc_textField.fill = GridBagConstraints.HORIZONTAL;
            gbc_textField.gridx = 1;
            gbc_textField.gridy = j + 1;
            textField[j].setColumns(10);
            p1.add(textField[j], gbc_textField);
        }
        panel = new JPanel();
        panel.setBackground(new Color(253, 245, 230));
        getContentPane().add(panel, BorderLayout.SOUTH);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWidths = new int[] { 0, 0, 57, 57, 0 };
        gbl_panel.rowHeights = new int[] { 23, 0 };
        gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0,Double.MIN_VALUE };
        gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
        panel.setLayout(gbl_panel);

        btnNewButton = new JButton("提交");// 提交按钮
        btnNewButton.setBackground(new Color(255, 228, 225));
        GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
        gbc_btnNewButton.anchor = GridBagConstraints.NORTHWEST;
        gbc_btnNewButton.insets = new Insets(0, 100, 20, 40);
        gbc_btnNewButton.gridx = 0;
        gbc_btnNewButton.gridy = 0;
        // btnNewButton.setEnabled(false);
        panel.add(btnNewButton, gbc_btnNewButton);

        button = new JButton("退出");// 退出按钮
        button.setBackground(new Color(250, 250, 210));
        GridBagConstraints gbc_button = new GridBagConstraints();
        gbc_button.insets = new Insets(0, 0, 20, 40);
        gbc_button.anchor = GridBagConstraints.NORTHWEST;
        gbc_button.gridx = 1;
        gbc_button.gridy = 0;
        panel.add(button, gbc_button);

        hybutton = new JButton("\u62A4\u773C\u6A21\u5F0F");
        hybutton.setBackground(new Color(152, 251, 152));
        GridBagConstraints gbc_hybutton = new GridBagConstraints();
        gbc_hybutton.anchor = GridBagConstraints.NORTHWEST;
        gbc_hybutton.insets = new Insets(0, 0, 0, 5);
        gbc_hybutton.gridx = 2;
        gbc_hybutton.gridy = 0;
        panel.add(hybutton, gbc_hybutton);

        btnNewButton.addActionListener(this);
        button.addActionListener(this);
        hybutton.addActionListener(this);

        this.setVisible(true);
    }

    public static void timu(int max, int[] num1) 
    {// 题目
        int n;
        char[] op = { '+', '-', '*', '/' };
        int[] no = new int[4];
        int cs;// 正负参数
        int ccs;// 题型参数
        String str = new String();

        for (int i = 0; i < max; i++) 
        {
            ccs = (int) (Math.random() * 2);
            s[i] = "(" + (i + 1) + ")";
            n = (int) (Math.random() * 4 + 2);// 2-5个操作数
            if (ccs == 0) {// 一般式子计算
                for (int j = 0; j < n; j++) 
                {
                    cs = (int) (Math.random() * 2);
                    if (cs == 0)// 负数
                        num1[j] = -(int) (Math.random() * 100);// 控制随机数数值
                    else// 正数
                        num1[j] = (int) (Math.random() * 100);// 控制随机数数值
                }
                for (int k = 0; k < n - 1; k++) 
                {
                    no[k] = (int) (Math.random() * 4);// 随机产生操作符
                    if (no[k] == 3 && num1[k + 1] == 0) 
                    {
                        do {
                            num1[k + 1] = (int) (Math.random() * 100);// 如果除号后为0,则重新取数。
                            } while (num1[k + 1] == 0);
                    }
                }
                for (int h = 0; h < n; h++) 
                {
                    if (h != n - 1) {
                        if (num1[h] < 0)
                            str = str + "(" + String.valueOf(num1[h]) + ")"+ String.valueOf(op[no[h]]);
                        else
                            str = str + String.valueOf(num1[h])+ String.valueOf(op[no[h]]);
                    } else {
                        if (num1[h] < 0)
                            str = str + "(" + String.valueOf(num1[h]) + ")=";
                        else
                            str = str + String.valueOf(num1[h]) + "=";
                    }
                }
                s[i] = s[i] + str;
                str = new String();
            } 
            else// 阶层式子计算
            {
                num2 = (int) (Math.random() * 11);
                s[i] = "(" + (i + 1) + ")" + String.valueOf(num2) + "!=";

            }
            if (ccs == 0) 
            {
                int sign; // 累加运算时的符号
                float left, right;// 保存蹭结果
                decimal.setRoundingMode(RoundingMode.HALF_UP);
                // 计算标准答案
                left = 0;
                right = num1[0];
                sign = 1;

                for (int g = 0; g < n - 1; g++) {
                    switch (op[no[g]]) {
                    case '+':
                        left = left + sign * right;
                        sign = 1;
                        right = num1[g + 1];
                        break;
                    case '-':
                        left = left + sign * right;
                        sign = -1;
                        right = num1[g + 1];
                        break;
                    case '*':
                        right = right * num1[g + 1];
                        break;
                    case '/':
                        right = right / num1[g + 1];
                        break;
                    }
                }
                staticanser[i] = String.valueOf(decimal.format(left + sign
                        * right));
                System.out.println((i + 1) + ":" + staticanser[i]);
            } else {
                int ann = 1;
                if (num2 == 0) {
                    staticanser[i] = "1";
                } else {
                    for (int o = 1; o <= num2; o++) {
                        ann = ann * o;
                    }
                    staticanser[i] = String.valueOf(ann);
                }
                System.out.println((i + 1) + ":" + staticanser[i]);

            }

        }

    }

    public static void main(String[] args) 
    {
        q1 = new Question();

    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

        if (e.getSource() == btnNewButton) // 提交按钮
        {
            for (int l = 0; l < n; l++) //获取文本框内容
                useranser[l] = textField[l].getText();
            
            int flag1=0;//检查用户输入是否符合范围,是否为数字
            for (int l = 0; l < n; l++) 
            {
                if (!pattern.matcher(textField[l].getText()).matches())// 如果输入的是数字就执行
                    flag1=1;
                
            }
            int flag = 0;//检查用户输入是否为空
            for (int l = 0; l < n; l++) 
            {
                if (textField[l].getText().isEmpty()) 
                    flag = 1;
            }
            if (flag != 1&&flag1!=1)//符合条件
            {
                this.setDefaultCloseOperation(Question.HIDE_ON_CLOSE);
                this.setVisible(false);
                Total to = new Total();
            } 
            else //为空,或者不是数字则提示错误
            {
                JOptionPane.showMessageDialog(q1, "未完成题目或答案无效,请继续答题!!", "错误信息",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

        if (e.getSource() == button)// 退出
        {
            System.exit(0);

        }

        if (e.getSource() == hybutton) {// 护眼模式
            p1.setBackground(new Color(204, 255, 153));
            panel.setBackground(new Color(204, 255, 153));
            
            hycs = 0;
        }
    }

}
import javax.swing.JFrame;

import java.awt.GridLayout;
import java.awt.GridBagLayout;

import javax.swing.JLabel;

import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import java.awt.Toolkit;

//统计的页面
public class Total extends JFrame implements ActionListener
{
    JLabel[] lable=new JLabel[5];
    JLabel[] lable1=new JLabel[5];
    JButton restart,quit;
    static Total to;
    int count=0;
    Total()
    {
        super("统计");
        setIconImage(Toolkit.getDefaultToolkit().getImage(Total.class.getResource("/img/33.jpg")));
        this.setSize(499, 383);
        this.setLocation(350, 50);//主窗口位置
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setResizable(true);
        getContentPane().setBackground(new Color(253, 245, 230));
        if(Question.hycs==0)
        {
            getContentPane().setBackground(new Color(204, 255, 153));
            
        }
        Question.hycs=1;
        GridBagLayout gridBagLayout = new GridBagLayout();
        gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
        gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
        gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
        gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
        getContentPane().setLayout(gridBagLayout);
        
        JLabel lblNewLabel_9 = new JLabel("分数统计");
        lblNewLabel_9.setFont(new Font("仿宋", Font.BOLD, 30));
        GridBagConstraints gbc_lblNewLabel_9 = new GridBagConstraints();
        gbc_lblNewLabel_9.gridwidth = 2;
        gbc_lblNewLabel_9.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_9.gridx = 1;
        gbc_lblNewLabel_9.gridy = 0;
        getContentPane().add(lblNewLabel_9, gbc_lblNewLabel_9);
        
        JLabel label = new JLabel("总共:"+Question.tmnum);
        label.setFont(new Font("仿宋", Font.PLAIN, 20));
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.fill = GridBagConstraints.HORIZONTAL;
        gbc_label.anchor = GridBagConstraints.WEST;
        gbc_label.insets = new Insets(0, 20, 5, 30);
        gbc_label.gridx = 1;
        gbc_label.gridy = 1;
        getContentPane().add(label, gbc_label);
    
        int cs[]=new int[2];
        for(int y=0;y<Question.n;y++)
        {
             try {
                  Double.parseDouble(Question.useranser[y]); //可以转换为整型;
                } 
               catch (Exception g) {
                   if(Question.useranser[y].equals(" "))
                   {
                       
                   }
                   else
                   {
                       String[] ss = new String[2];
                       ss = Question.useranser[y].split("/");
                       cs[0] = Integer.valueOf(ss[0]);
                       cs[1] = Integer.valueOf(ss[1]);
                       double answer = (double) cs[0] / (double)cs[1];
                       Question.useranser[y]=Question.decimal.format(answer);
                    }
               }
            
            if(Question.useranser[y].equalsIgnoreCase(Question.staticanser[y]))
                count++;
        }
        JLabel lblNewLabel = new JLabel("答对:"+String.valueOf(count)+"题");
        lblNewLabel.setFont(new Font("仿宋", Font.PLAIN, 20));
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.fill = GridBagConstraints.HORIZONTAL;
        gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
        gbc_lblNewLabel.insets = new Insets(0, 20, 5, 30);
        gbc_lblNewLabel.gridx = 1;
        gbc_lblNewLabel.gridy = 2;
        getContentPane().add(lblNewLabel, gbc_lblNewLabel);
        
        
        
        JLabel lblNewLabel_1 = new JLabel("答错:"+String.valueOf(Question.n-count)+"题");
        lblNewLabel_1.setFont(new Font("仿宋", Font.PLAIN, 20));
        GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
        gbc_lblNewLabel_1.fill = GridBagConstraints.HORIZONTAL;
        gbc_lblNewLabel_1.anchor = GridBagConstraints.WEST;
        gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 30);
        gbc_lblNewLabel_1.gridx = 2;
        gbc_lblNewLabel_1.gridy = 2;
        getContentPane().add(lblNewLabel_1, gbc_lblNewLabel_1);
        
        JLabel lblNewLabel_2 = new JLabel("正确率:"+String.valueOf(Question.decimal.format(((float) count / (float) Question.n) * 100))+"%");
        lblNewLabel_2.setFont(new Font("仿宋", Font.PLAIN, 20));
        GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
        gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_2.fill = GridBagConstraints.HORIZONTAL;
        gbc_lblNewLabel_2.anchor = GridBagConstraints.WEST;
        gbc_lblNewLabel_2.gridx = 2;
        gbc_lblNewLabel_2.gridy = 1;
        getContentPane().add(lblNewLabel_2, gbc_lblNewLabel_2);
        
        JLabel lblNewLabel_7 = new JLabel("用户答案:");
        lblNewLabel_7.setBackground(new Color(245, 255, 250));
        lblNewLabel_7.setFont(new Font("仿宋", Font.BOLD, 30));
        GridBagConstraints gbc_lblNewLabel_7 = new GridBagConstraints();
        gbc_lblNewLabel_7.gridwidth = 2;
        gbc_lblNewLabel_7.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_7.gridx = 1;
        gbc_lblNewLabel_7.gridy = 3;
        getContentPane().add(lblNewLabel_7, gbc_lblNewLabel_7);
        
        for(int i=0;i<Question.n;i++){
            lable1[i] = new JLabel(Question.s[i]+Question.useranser[i]);
            lable1[i].setFont(new Font("仿宋", Font.PLAIN, 20));
        GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
        gbc_lblNewLabel_3.anchor = GridBagConstraints.WEST;
        gbc_lblNewLabel_3.gridwidth = 2;
        gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_3.gridx = 1;
        gbc_lblNewLabel_3.gridy = i+4;
        getContentPane().add(lable1[i], gbc_lblNewLabel_3);
        }
        
        JLabel lblNewLabel_8 = new JLabel("参考答案:");
        lblNewLabel_8.setBackground(new Color(245, 255, 250));
        lblNewLabel_8.setFont(new Font("仿宋", Font.BOLD, 30));
        GridBagConstraints gbc_lblNewLabel_8 = new GridBagConstraints();
        gbc_lblNewLabel_8.gridwidth = 2;
        gbc_lblNewLabel_8.insets = new Insets(0, 0, 5, 0);
        gbc_lblNewLabel_8.gridx = 3;
        gbc_lblNewLabel_8.gridy = 3;
        getContentPane().add(lblNewLabel_8, gbc_lblNewLabel_8);
        
        for(int i=0;i<Question.n;i++){
            lable[i] = new JLabel("("+(i+1)+")"+Question.staticanser[i]);
            lable[i].setFont(new Font("仿宋", Font.PLAIN, 20));
        GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
        gbc_lblNewLabel_3.anchor = GridBagConstraints.WEST;
        gbc_lblNewLabel_3.gridwidth = 2;
        gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_3.gridx = 3;
        gbc_lblNewLabel_3.gridy = i+4;
        getContentPane().add(lable[i], gbc_lblNewLabel_3);
        }
        

        restart = new JButton("重新开始");
        restart.setBackground(new Color(255, 255, 153));
        GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
        gbc_btnNewButton.anchor = GridBagConstraints.WEST;
        gbc_btnNewButton.insets = new Insets(0, 0, 0, 5);
        gbc_btnNewButton.gridx = 2;
        gbc_btnNewButton.gridy = 9;
        getContentPane().add(restart, gbc_btnNewButton);
        restart.addActionListener(this);
        
        quit = new JButton("  \u9000\u51FA  ");
        quit.setBackground(new Color(255, 255, 153));
        GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
        gbc_btnNewButton_1.insets = new Insets(0, 0, 0, 5);
        gbc_btnNewButton_1.gridx = 3;
        gbc_btnNewButton_1.gridy = 9;
        getContentPane().add(quit, gbc_btnNewButton_1);
        quit.addActionListener(this);
        this.setVisible(true);
    }
    public static void main(String[] args) {
        to=new Total();

    }
    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        if(e.getSource()==restart)
        {
            this.dispose();
            Menu m=new Menu();    
        }
        else if(e.getSource()==quit)
        {
            System.exit(0);
        }
        

    }

}

 

一、程序执行:

1、开始界面

 

2、提示输入题量(对话框)

输入1~5内的数字:会跳转到出题的界面

             如果输入1~5以外的数字:

    输入非数字:

 

3、出题界面,根据用户输入的题量出题

 

4、用户输入答案,如果没有做完就提交会弹出提示框要填完才能提交,输入的答案不是数字提交也会提示

 

5、统计结果界面(答对多少题,打错多少题,正确率,答案之类)

 

6、判断用户输入的答案,用户可以输入分数,也可以输入小数,并且支持四舍五入计算小数点后两位:

 

 

 

7、换肤模式,在出题框架里点击换肤模式会更换皮肤

 

 

 

  开发环境:Eclipse

      程序完成的方向:

  1. 程序可以出带括号的正整数四则运算,支持分数,除法保留两位小数,如:(1/3+1)*2 = 2.67,特别注意:这里是2.67而非2.66,或保持分数形式:8/3
  1. 可以出表达式里含有负整数(负整数最小不小于-100)的题目,且负数需要带括号,用户输入的结果不用带括号。如: 2*(-4) = -8
  2. 用户可以选择出题的个数(最多不能超过5个题目),答题结束可以显示用户答错的题目个数和答对的题目个数
  3. 程序可以出单个整数阶乘的题目:如:4!=24
  4. 程序可以设置皮肤功能,可以改变界面的颜色即可。

 

结对同伴:

 

姓名

学号

博客地址

冯美欣

201306114451

http://www.cnblogs.com/maxx/

林欢雯

201306114450

http://www.cnblogs.com/wzhz/

 

   正如书上说的,在结对编程里,没有我的代码,或你的代码,只有我们的代码,在这次的结对编程里面我跟我的同伴两人在领航员,驾驶员的角色中切换工作,在编程过程中存在激烈的讨论,遇到困难在网上收集资料解决难题。可以说程序里的每一个部分都是一起完成,因为我们在一起睡了几个晚上,哈~~~

总结:       

收获:在这次的结对编程里面,给我很不一样的感觉,感觉是一个小团队的感觉,之前的编程都是自己一个人完成比较多,很少有这种感觉,在于同伴一起完成,收获了以下几点:

1、无论做什么都要先理顺思路,要一个什么东西,基本框架是什么,每一个界面的大概模型,还有基本功能是什么,都要先考虑好才能动手,不然会很混乱;

2、在写代码的时候思路一定要清晰,就算遇到可恶的bug(八阿哥)也不能急,从错误的地方一条一条代码地检查,就很快你那个找错错误的地方;

3、发现自己界面方面的知识基础不行,要多点掌握或者去了解一下这些类有哪些方法属性,只有掌握好基础才能更好更灵活地写出更好地程序;

 

感悟:

    经过这次的结对练习,感觉团队是个好东西,他可以让每个人看到自己不足,也能让自己发现自身好的地方,而且在遇到关卡时不用一个人在那里抓狂,有一个人可以陪你一起激烈的讨论,不断的调试,把bug一个一个地解决掉,那种感觉真的倍爽!!

我会发现自己需要多点了解java,多点了解怎么实现一些小功能,保留两位,四舍五入,框架地属性之类地,要稳扎根基。

在弄这个结对练习这段时间真的好有冲劲,超享受的虽然弄出来的程序不是很完美,但是程序的代码我们一起打出来的,比完美的程序更珍贵~

 

工作图可以去看我的同伴的博客:

林欢雯:http://www.cnblogs.com/wzhz/

posted @ 2015-04-09 10:23  51冯美欣max  阅读(287)  评论(1编辑  收藏  举报