开发环境:Eclipse
程序完成的方向:
- 程序可以出带括号的正整数四则运算,支持分数,除法保留两位小数,如:(1/3+1)*2 = 2.67,特别注意:这里是2.67而非2.66,或保持分数形式:8/3
- 可以出表达式里含有负整数(负整数最小不小于-100)的题目,且负数需要带括号,用户输入的结果不用带括号。如: 2*(-4) = -8
- 用户答题结束以后,程序可以显示用户答题所用的时间
- 用户可以选择出题的个数(最多不能超过5个题目),答题结束可以显示用户答错的题目个数和答对的题目个数
- 用户在第一次答题时,需要用户输入用户名,用户下次启动后,程序需要记住用户前一次输入的用户名
- 程序可以出单个整数阶乘的题目:如:4!=24
- 程序可以设置答题时间,时间设置为整数,单位为秒,最大不能超过120秒,若超过了答题时间未答题,则提示:时间已到,不能答题。
结对同伴:
姓名 | 学号 | 博客地址 |
黄铭琪 | 201306114449 | http://www.cnblogs.com/mikky/ |
欧阳可圣 | 201306114418 | http://www.cnblogs.com/kevinkeke/ |
收获:
1.在这一次的结对编程过程中,我们两个始终交替互换着“领航员”与“驾驶员”的身份。我们一起讨论,更加注重细节,确保我们能够在最短的时间做出最好的作
品。编程的过程始终是很烦闷的,但一起合作却让我们不再孤单,偶尔的调侃让我们的编程经历更显乐趣。
2.结对的时候会遇到很多问题,意见上的不统一,观点上的分歧,更多的是编程习惯的不同,但经过了这一次的磨合,我们相互学习,让我们懂得了怎样去向他
人学习,从不同方面去改善自己的缺点和不足,做到“更好更优更完善”。
3.结对编程让我们主动去学习新知识,从不同角度去尝试不同的结对编程,学会打破自己的一贯的编程方式,学习不同的风格,使得自己的编程水平有一个显著
的提高。
感悟:
- 正如书上说的,“只有水平上的差距,没有级别上的差距。”很明显我们两个是在水平上市有所差距的,但我的同伴总是能够锲而不舍的帮助我,引导我学到更多东西。现实生活中很多问题在课本上都是找不到答案的,需要我们主动去探索、去寻找更完美的答案。
- 由于我跟我的同伴不是住在一起的,没办法一直进行讨论,因此,我们格外珍惜在一起讨论的时间,学会了珍惜时间。
- 每晚睡前我们都会思考程序要怎样才能更加完善,一有新想法就告诉对方,仿若发现了珍宝一般,从一定程度上锻炼了我们的逻辑思维。
- 课本上的知识是有限的,人类的创造力却是无穷的,遇到不懂的,要主动地学习,从不同的资源汲取最全面的知识,“时刻保持一颗主动的心”便是最大的感悟了。
- 任何一个时刻,任何一个任务,都是两个人得责任,也是所有人的责任。书上说,“没有'我的代码'、'你的代码'或‘他/她的代码',只有'我们的代码'。”我们之间是不分彼此的,所有的扩展方向都是我们一起做出来的,它是我们“共同的孩子”。
- 代码:(ps:我们程序中的文件保存路径为:String dirname="C:/Users/Administrator/Desktop/OYKS/OYKS/Strongest";调试的时候需要老师更改一下)
-
package size; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.io.*; import java.util.ArrayList; import java.util.Date; public class login extends JFrame implements ActionListener{ private static final long serialVersionUID = 1L; private JTextField textField; public JButton btnNewButton_1,btnNewButton; public int w=0,ww; public login() { super("登陆界面"); getContentPane().setBackground(new Color(0, 0, 139)); getContentPane().setForeground(new Color(0, 0, 205)); setSize(345,266); setVisible(true); //将窗口设置为可视 setResizable(false); setAlwaysOnTop(true);//设置此窗口永远为最上方 是window的方法 setLocationRelativeTo(null); getContentPane().setLayout(null); textField = new JTextField(); textField.setBounds(86, 85, 162, 21); getContentPane().add(textField); textField.setColumns(10); btnNewButton = new JButton("\u767B\u9646"); btnNewButton.setFont(new Font("幼圆", Font.BOLD, 12)); btnNewButton.setForeground(new Color(255, 0, 0)); btnNewButton.setBounds(51, 157, 93, 23); btnNewButton.addActionListener(this); getContentPane().add(btnNewButton); btnNewButton_1 = new JButton("\u6CE8\u518C"); btnNewButton_1.setFont(new Font("幼圆", Font.BOLD, 12)); btnNewButton_1.setForeground(new Color(255, 0, 0)); btnNewButton_1.setBounds(193, 157, 93, 23); btnNewButton_1.addActionListener(this); getContentPane().add(btnNewButton_1); JLabel label = new JLabel("\u767B\u5F55\u540D"); label.setForeground(new Color(255, 0, 0)); label.setFont(new Font("幼圆", Font.BOLD, 19)); label.setBounds(138, 38, 66, 21); getContentPane().add(label); } public void save(String mm) //******************************************************************************* { String dirname="C:/Users/Administrator/Desktop/OYKS/OYKS/Strongest"; try{ File dir=new File(dirname); if(!dir.exists()) dir.mkdir(); else if(!dir.isDirectory()) { System.out.print(dirname+"不是目录路径"); return; } File afile=new File(dir,"ys.txt"); afile.createNewFile(); BufferedWriter bs = new BufferedWriter(new FileWriter(afile,true)); //使用BufferedWriter写入文本时不用将文本转换成字节数组 追加式的。 bs.write(mm); bs.flush(); bs.close(); } catch (IOException e) { System.out.print("IOexception throun:"+e); } } //* public String []reademp(File output) //文件读取 { ArrayList<String> ee = new ArrayList<String>();//动态数组ArrayList的ee对象里面放的必须是employee类型的 try { BufferedReader br = new BufferedReader(new FileReader(output)); //通过FileReader打开,然后在BufferedReader中进行缓冲读取 String temp = ""; //它可以包装字符流,将字符流放入缓存里,先把字符读到缓存里,到缓存满了或者flush的时候,再读入内存, while ((temp = br.readLine()) != null) {//读到文本为空为止。
package size; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.io.*; import java.util.Date; public class select extends JFrame implements ActionListener{ public JButton btnNewButton_jiecheng; public JButton btnNewButton_size; public select() { super("选择界面"); setSize(345,266); setVisible(true); //将窗口设置为可视 setResizable(false); setAlwaysOnTop(true);//设置此窗口永远为最上方 是window的方法 setLocationRelativeTo(null); getContentPane().setLayout(null); JPanel panel = new JPanel(); panel.setBackground(new Color(0, 0, 139)); panel.setForeground(Color.BLUE); panel.setBounds(0, 0, 339, 239); getContentPane().add(panel); panel.setLayout(null); btnNewButton_size = new JButton("\u56DB\u5219\u8FD0\u7B97"); btnNewButton_size.setForeground(Color.RED); btnNewButton_size.setBounds(128, 76, 93, 23); btnNewButton_size.addActionListener(this); panel.add(btnNewButton_size); btnNewButton_jiecheng = new JButton("\u9636\u4E58\u8FD0\u7B97"); btnNewButton_jiecheng.setForeground(Color.RED); btnNewButton_jiecheng.setBounds(128, 142, 93, 23); btnNewButton_jiecheng.addActionListener(this); panel.add(btnNewButton_jiecheng); } public void actionPerformed(ActionEvent e) { if(e.getSource()==btnNewButton_size) { new newFrame1(); } else if(e.getSource()==btnNewButton_jiecheng) { new newFrame2(); } } public static void main(String[]args) { new select(); } }
package size; //import test2; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.Random; import java.util.Scanner; public class newFrame extends JFrame implements ActionListener{ public JButton btnNewButton_1,btnNewButton; public JComboBox List; public JTextField textField_2; public JTextField textField_zhengshi1; public JTextField textField_daan1; public JTextField textField_zhengshi2; public JTextField textField_daan2; public JTextField textField_zhengshi3; public JTextField textField_daan3; public JTextField textField_zhengshi4; public JTextField textField_daan4; public JTextField textField_zhengshi5; public JTextField textField_daan5; public JTextField textField_duicuo1; public JTextField textField_duicuo2; public JTextField textField_duicuo3; public JTextField textField_duicuo4; public JTextField textField_duicuo5; public JTextField textField_zhengque1; public JTextField textField_zhengque2; public JTextField textField_zhengque3; public JTextField textField_zhengque4; public JTextField textField_zhengque5; public JTextField textField_shijian1; public JTextField textField_shijian2; public JTextField textField_shijian3; public JTextField textField_shijian4; public JTextField textField_shijian5; public JTextField textField_zq; public JTextField textField_zql; public JTextField textField_allshijian; public JButton button_daan; public JButton btnNewButton_queding; public JButton btnNewButton_jixv; public String x; public String []c=new String [10]; public Test t; public static int num=0; public static int num1=0; public long begin,end,sum; private JLabel label_4; private JLabel label_5; private JLabel label_6; private JLabel label_7; public newFrame(String a[]) { super("四则运算"); c=a; getContentPane().setLayout(null); JPanel panel = new JPanel(); panel.setForeground(new Color(255, 0, 102)); setSize(725, 463); panel.setBounds(0, 0, 719, 435); getContentPane().add(panel); panel.setLayout(null); String[] zw={"随机","1","2","3","4","5"}; List=new JComboBox(zw); List.setEnabled(false); List.addActionListener(this); List.setFont(new Font("宋体", Font.PLAIN, 13)); List.setBounds(10, 10, 75, 21); panel.add(List); textField_zhengshi1 = new JTextField(); textField_zhengshi1.setEditable(false); textField_zhengshi1.setBounds(10, 77, 240, 21); panel.add(textField_zhengshi1); textField_zhengshi1.setColumns(50); textField_zhengshi1.setText(a[0]); textField_zhengshi1.addActionListener(this); textField_daan1 = new JTextField(); textField_daan1.setBounds(286, 77, 102, 21); panel.add(textField_daan1); textField_daan1.addActionListener(this); textField_daan1.setColumns(20); textField_zhengshi2 = new JTextField(); textField_zhengshi2.setEditable(false); textField_zhengshi2.setBounds(10, 120, 240, 21); panel.add(textField_zhengshi2); textField_zhengshi2.setText(a[2]); textField_zhengshi2.setColumns(50); textField_daan2 = new JTextField(); textField_daan2.setBounds(286, 120, 102, 21); panel.add(textField_daan2); textField_daan2.addActionListener(this); textField_daan2.setColumns(20); textField_zhengshi3 = new JTextField(); textField_zhengshi3.setEditable(false); textField_zhengshi3.setBounds(10, 163, 240, 21); panel.add(textField_zhengshi3); textField_zhengshi3.setText(a[4]); textField_zhengshi3.setColumns(50); textField_daan3 = new JTextField(); textField_daan3.setBounds(286, 163, 102, 21); panel.add(textField_daan3); textField_daan3.addActionListener(this); textField_daan3.setColumns(20); textField_zhengshi4 = new JTextField(); textField_zhengshi4.setEditable(false); textField_zhengshi4.setBounds(10, 206, 240, 21); panel.add(textField_zhengshi4); textField_zhengshi4.setText(a[6]); textField_zhengshi4.setColumns(50); textField_daan4 = new JTextField(); textField_daan4.setText(""); textField_daan4.setBounds(286, 206, 102, 21); panel.add(textField_daan4); textField_daan4.addActionListener(this); textField_daan4.setColumns(10); textField_zhengshi5 = new JTextField(); textField_zhengshi5.setEditable(false); textField_zhengshi5.setBounds(10, 249, 240, 21); panel.add(textField_zhengshi5); textField_zhengshi5.setText(a[8]); textField_zhengshi5.setColumns(50); textField_daan5 = new JTextField(); textField_daan5.setBounds(286, 249, 102, 21); panel.add(textField_daan5); textField_daan5.addActionListener(this); textField_daan5.setColumns(20); textField_duicuo1 = new JTextField(); textField_duicuo1.setForeground(Color.RED); textField_duicuo1.setBackground(Color.WHITE); textField_duicuo1.setBounds(422, 77, 37, 21); panel.add(textField_duicuo1); textField_duicuo1.setColumns(10); textField_duicuo2 = new JTextField(); textField_duicuo2.setForeground(Color.RED); textField_duicuo2.setEnabled(true); textField_duicuo2.setText(""); textField_duicuo2.setBounds(422, 120, 37, 21); panel.add(textField_duicuo2); textField_duicuo2.setColumns(10); textField_duicuo3 = new JTextField(); textField_duicuo3.setForeground(Color.RED); textField_duicuo3.setEnabled(true); textField_duicuo3.setText(""); textField_duicuo3.setBounds(422, 163, 37, 21); panel.add(textField_duicuo3); textField_duicuo3.setColumns(10); textField_duicuo4 = new JTextField(); textField_duicuo4.setForeground(Color.RED); textField_duicuo4.setEnabled(true); textField_duicuo4.setText(""); textField_duicuo4.setBounds(422, 206, 37, 21); panel.add(textField_duicuo4); textField_duicuo4.setColumns(10); textField_duicuo5 = new JTextField(); textField_duicuo5.setForeground(Color.RED); textField_duicuo5.setEnabled(true); textField_duicuo5.setText(""); textField_duicuo5.setBounds(422, 249, 37, 21); panel.add(textField_duicuo5); textField_duicuo5.setColumns(10); textField_zhengque1 = new JTextField(); textField_zhengque1.setForeground(Color.BLUE); textField_zhengque1.setEditable(false); textField_zhengque1.setBounds(499, 77, 102, 21); panel.add(textField_zhengque1); textField_zhengque1.setColumns(20); textField_zhengque2 = new JTextField(); textField_zhengque2.setForeground(Color.BLUE); textField_zhengque2.setEditable(false); textField_zhengque2.setEnabled(true); textField_zhengque2.setText(""); textField_zhengque2.setBounds(499, 120, 102, 21); panel.add(textField_zhengque2); textField_zhengque2.setColumns(20); textField_zhengque3 = new JTextField(); textField_zhengque3.setForeground(Color.BLUE); textField_zhengque3.setEditable(false); textField_zhengque3.setBounds(499, 163, 102, 21); panel.add(textField_zhengque3); textField_zhengque3.setColumns(20); textField_zhengque4 = new JTextField(); textField_zhengque4.setForeground(Color.BLUE); textField_zhengque4.setEditable(false); textField_zhengque4.setBounds(499, 206, 102, 21); panel.add(textField_zhengque4); textField_zhengque4.setColumns(20); textField_zhengque5 = new JTextField(); textField_zhengque5.setForeground(Color.BLUE); textField_zhengque5.setEditable(false); textField_zhengque5.setEnabled(true); textField_zhengque5.setText(""); textField_zhengque5.setBounds(499, 249, 102, 21); panel.add(textField_zhengque5); textField_zhengque5.setColumns(20); textField_shijian1 = new JTextField(); textField_shijian1.setForeground(new Color(255, 0, 102)); textField_shijian1.setEditable(false); textField_shijian1.setBounds(621, 77, 66, 21); panel.add(textField_shijian1); textField_shijian1.setColumns(30); textField_shijian2 = new JTextField(); textField_shijian2.setForeground(new Color(255, 0, 102)); textField_shijian2.setEnabled(true); textField_shijian2.setEditable(false); textField_shijian2.setText(""); textField_shijian2.setBounds(621, 120, 66, 21); panel.add(textField_shijian2); textField_shijian2.setColumns(30); textField_shijian3 = new JTextField(); textField_shijian3.setForeground(new Color(255, 0, 102)); textField_shijian3.setEnabled(true); textField_shijian3.setEditable(false); textField_shijian3.setText(""); textField_shijian3.setBounds(621, 163, 66, 21); panel.add(textField_shijian3); textField_shijian3.setColumns(30); textField_shijian4 = new JTextField(); textField_shijian4.setForeground(new Color(255, 0, 102)); textField_shijian4.setEnabled(true); textField_shijian4.setEditable(false); textField_shijian4.setText(""); textField_shijian4.setBounds(621, 206, 66, 21); panel.add(textField_shijian4); textField_shijian4.setColumns(30); textField_shijian5 = new JTextField(); textField_shijian5.setForeground(new Color(255, 0, 102)); textField_shijian5.setEnabled(true); textField_shijian5.setEditable(false); textField_shijian5.setText(""); textField_shijian5.setBounds(621, 249, 66, 21); panel.add(textField_shijian5); textField_shijian5.setColumns(30); textField_zq = new JTextField(); textField_zq.setEditable(false); textField_zq.setBounds(10, 340, 66, 21); panel.add(textField_zq); textField_zq.setColumns(20); textField_zql = new JTextField(); textField_zql.setEnabled(true); textField_zql.setEditable(false); textField_zql.setText(""); textField_zql.setBounds(96, 340, 66, 21); panel.add(textField_zql); textField_zql.setColumns(20); textField_allshijian = new JTextField(); textField_allshijian.setEditable(false); textField_allshijian.setBounds(621, 340, 66, 21); panel.add(textField_allshijian); textField_allshijian.setColumns(30); button_daan = new JButton("答案"); button_daan.addActionListener(this); button_daan.setBounds(351, 391, 81, 23); panel.add(button_daan); btnNewButton_queding = new JButton("确定"); btnNewButton_queding.setBounds(471, 391, 81, 23); btnNewButton_queding.addActionListener(this); panel.add(btnNewButton_queding); btnNewButton_jixv = new JButton("继续答题"); btnNewButton_jixv.setBounds(590, 391, 97, 23); btnNewButton_jixv.addActionListener(this); panel.add(btnNewButton_jixv); JLabel label = new JLabel("\u9898\u76EE"); label.setBounds(10, 52, 54, 15); panel.add(label); JLabel label_1 = new JLabel("\u8F93\u5165\u7B54\u6848"); label_1.setBounds(286, 52, 54, 15); panel.add(label_1); JLabel label_2 = new JLabel("\u5224\u65AD"); label_2.setBounds(422, 52, 54, 15); panel.add(label_2); JLabel label_3 = new JLabel("\u53C2\u8003\u7B54\u6848"); label_3.setBounds(499, 52, 54, 15); panel.add(label_3); label_4 = new JLabel("\u7B54\u9898\u65F6\u95F4"); label_4.setBounds(621, 52, 54, 15); panel.add(label_4); label_5 = new JLabel("\u603B\u65F6\u95F4"); label_5.setBounds(621, 315, 54, 15); panel.add(label_5); label_6 = new JLabel("\u6B63\u786E\u9898\u6570"); label_6.setForeground(Color.RED); label_6.setBounds(10, 315, 54, 15); panel.add(label_6); label_7 = new JLabel("\u6B63\u786E\u7387"); label_7.setForeground(Color.RED); label_7.setBounds(96, 315, 54, 15); panel.add(label_7); Test t=new Test(); // t.start(); begin=System.currentTimeMillis(); setVisible(true); //将窗口设置为可视 setResizable(false); setAlwaysOnTop(true);//设置此窗口永远为最上方 是window的方法 setLocationRelativeTo(null); getContentPane().setLayout(null); } public void setx(String x) { this.x=x; } public String getx() { return x; } public void actionPerformed(ActionEvent e) { if(e.getSource()==button_daan) { textField_zhengque1.setText(c[1]); textField_zhengque2.setText(c[3]); textField_zhengque3.setText(c[5]); textField_zhengque4.setText(c[7]); textField_zhengque5.setText(c[9]); //emp[i]=new employee(); //x=(String) List.getSelectedItem(); //System.out.print(x); //zanshi k=new zanshi(); //k.setx((String) List.getSelectedItem()); //System.out.print(k.getx()); //System.out.print(x); //List.requestFocusInWindow(); //new test2(x); //newFrame b=new newFrame(""); //textField_zhengshi1.setText(a[0]); } //try{ //10000毫秒以后结束线程 //Thread.sleep(5000); else if(e.getSource()==textField_daan1)//职务 { if(textField_daan1.getText().equals(c[1])) { textField_duicuo1.setText("√"); //t.stop(); //end=System.currentTimeMillis(); sum=(System.currentTimeMillis()-begin)/1000; textField_shijian1.setText(String.valueOf(sum)+"s"); textField_daan2.requestFocusInWindow(); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } else { textField_duicuo1.setText("×"); sum=(System.currentTimeMillis()-begin)/1000; textField_shijian1.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian1.setText(String.valueOf(t.time)); //t.stop();textField_daan2.requestFocusInWindow(); textField_daan2.requestFocusInWindow(); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } else if(e.getSource()==textField_daan2)//职务 { if(textField_daan2.getText().equals(c[3])) { textField_duicuo2.setText("√"); sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian2.setText(String.valueOf(sum)+"s"); //textField_shijian2.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } else { if(c[3].equals("")) { textField_duicuo2.setText("none"); } else { textField_duicuo2.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian2.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian2.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } textField_daan3.requestFocusInWindow(); } else if(e.getSource()==textField_daan3)//职务 { Test t=new Test(); t.start(); if(textField_daan3.getText().equals(c[5])) { textField_duicuo3.setText("√"); sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian3.setText(String.valueOf(sum)+"s"); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); //textField_shijian3.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); } else { if(c[5].equals("")) { textField_duicuo3.setText("none"); } else { textField_duicuo3.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian3.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian3.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } textField_daan4.requestFocusInWindow(); } else if(e.getSource()==textField_daan4)//职务 { if(textField_daan4.getText().equals(c[7])) { textField_duicuo4.setText("√"); sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian4.setText(String.valueOf(sum)+"s"); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); //textField_shijian4.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); } else { if(c[7].equals("")) { textField_duicuo4.setText("none"); } else { textField_duicuo4.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian4.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian4.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } textField_daan5.requestFocusInWindow(); } else if(e.getSource()==textField_daan5)//职务 { if(textField_daan5.getText().equals(c[9])) { sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian5.setText(String.valueOf(sum)+"s"); //textField_shijian5.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_duicuo5.setText("√"); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } else { if(c[9].equals("")) { textField_duicuo5.setText("none"); } else { textField_duicuo5.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian5.setText(String.valueOf(sum)+"s"); //textField_shijian5.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } btnNewButton_queding.requestFocusInWindow(); } //} //} //catch(InterruptedException e1) //{ //e1.printStackTrace(); //} else if(e.getSource()==btnNewButton_queding)//职务 { //t.stop(); textField_allshijian.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)+"s"); } else if(e.getSource()==btnNewButton_jixv)//职务 { //t.stop(); //textField_allshijian.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)+"s"); setVisible(false); new newFrame1(); } /*if(e.getSource()==button_daan)//职务 { //x=(String) List.getSelectedItem(); new test2(x); }*/ /*if(e.getSource()==button_daan)//职务 { //x=(String) List.getSelectedItem(); new test2(x); } */ } }
package size; //import test2; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.Random; import java.util.Scanner; public class newFrame1 extends JFrame implements ActionListener{ public JButton btnNewButton_1,btnNewButton; public JComboBox List; public JTextField textField_2; public JTextField textField_zhengshi1; public JTextField textField_daan1; public JTextField textField_zhenshi2; public JTextField textField_daan2; public JTextField textField_zhengshi3; public JTextField textField_daan; public JTextField textField_zhengshi4; public JTextField textField; public JTextField textField_zhengshi5; public JTextField textField_daan5; public JTextField textField_duicuo1; public JTextField textField_duicuo2; public JTextField textField_duicuo3; public JTextField textField_duicuo4; public JTextField textField_duicuo5; public JTextField textField_zhengque1; public JTextField textField_zhengque2; public JTextField textField_zhrngque3; public JTextField textField_zhengque4; public JTextField textField_zhengque5; public JTextField textField_shijian1; public JTextField textField_shijian2; public JTextField textField_shijian3; public JTextField textField_shijian4; public JTextField textField_shijian5; public JTextField textField_zq; public JTextField textField_zql; public JTextField textField_allshijian; public JButton btnNewButton_queding; public JButton btnNewButton_jixv; public String x; private JLabel label; public newFrame1() { super("四则运算"); getContentPane().setLayout(null); JPanel panel = new JPanel(); panel.setForeground(Color.GRAY); setSize(725, 463); panel.setBounds(0, 0, 719, 435); getContentPane().add(panel); panel.setLayout(null); String[] zw={"随机","1","2","3","4","5"}; List=new JComboBox(zw); List.addActionListener(this); List.setFont(new Font("宋体", Font.PLAIN, 13)); List.setBounds(10, 10, 75, 21); panel.add(List); textField_zhengshi1 = new JTextField(); textField_zhengshi1.setEditable(false); textField_zhengshi1.setBounds(10, 77, 358, 21); panel.add(textField_zhengshi1); textField_zhengshi1.setColumns(50); textField_zhengshi1.addActionListener(this); textField_daan1 = new JTextField(); textField_daan1.setEditable(false); textField_daan1.setBounds(402, 77, 66, 21); panel.add(textField_daan1); textField_daan1.setColumns(20); textField_zhenshi2 = new JTextField(); textField_zhenshi2.setEditable(false); textField_zhenshi2.setBounds(10, 120, 358, 21); panel.add(textField_zhenshi2); textField_zhenshi2.setColumns(50); textField_daan2 = new JTextField(); textField_daan2.setEditable(false); textField_daan2.setBounds(402, 120, 66, 21); panel.add(textField_daan2); textField_daan2.setColumns(20); textField_zhengshi3 = new JTextField(); textField_zhengshi3.setEditable(false); textField_zhengshi3.setBounds(10, 163, 358, 21); panel.add(textField_zhengshi3); textField_zhengshi3.setColumns(50); textField_daan = new JTextField(); textField_daan.setEditable(false); textField_daan.setBounds(402, 163, 66, 21); panel.add(textField_daan); textField_daan.setColumns(20); textField_zhengshi4 = new JTextField(); textField_zhengshi4.setEditable(false); textField_zhengshi4.setBounds(10, 206, 358, 21); panel.add(textField_zhengshi4); textField_zhengshi4.setColumns(50); textField = new JTextField(); textField.setEditable(false); textField.setText(""); textField.setBounds(402, 206, 66, 21); panel.add(textField); textField.setColumns(10); textField_zhengshi5 = new JTextField(); textField_zhengshi5.setEditable(false); textField_zhengshi5.setBounds(10, 249, 358, 21); panel.add(textField_zhengshi5); textField_zhengshi5.setColumns(50); textField_daan5 = new JTextField(); textField_daan5.setEditable(false); textField_daan5.setBounds(402, 249, 66, 21); panel.add(textField_daan5); textField_daan5.setColumns(20); textField_duicuo1 = new JTextField(); textField_duicuo1.setEditable(false); textField_duicuo1.setBounds(488, 77, 37, 21); panel.add(textField_duicuo1); textField_duicuo1.setColumns(10); textField_duicuo2 = new JTextField(); textField_duicuo2.setEditable(false); textField_duicuo2.setEnabled(true); textField_duicuo2.setText(""); textField_duicuo2.setBounds(488, 120, 37, 21); panel.add(textField_duicuo2); textField_duicuo2.setColumns(10); textField_duicuo3 = new JTextField(); textField_duicuo3.setEnabled(true); textField_duicuo3.setEditable(false); textField_duicuo3.setText(""); textField_duicuo3.setBounds(488, 163, 37, 21); panel.add(textField_duicuo3); textField_duicuo3.setColumns(10); textField_duicuo4 = new JTextField(); textField_duicuo4.setEnabled(true); textField_duicuo4.setEditable(false); textField_duicuo4.setText(""); textField_duicuo4.setBounds(488, 206, 37, 21); panel.add(textField_duicuo4); textField_duicuo4.setColumns(10); textField_duicuo5 = new JTextField(); textField_duicuo5.setEnabled(true); textField_duicuo5.setEditable(false); textField_duicuo5.setText(""); textField_duicuo5.setBounds(488, 249, 37, 21); panel.add(textField_duicuo5); textField_duicuo5.setColumns(10); textField_zhengque1 = new JTextField(); textField_zhengque1.setEditable(false); textField_zhengque1.setBounds(535, 77, 66, 21); panel.add(textField_zhengque1); textField_zhengque1.setColumns(20); textField_zhengque2 = new JTextField(); textField_zhengque2.setEditable(false); textField_zhengque2.setEnabled(true); textField_zhengque2.setText(""); textField_zhengque2.setBounds(535, 120, 66, 21); panel.add(textField_zhengque2); textField_zhengque2.setColumns(20); textField_zhrngque3 = new JTextField(); textField_zhrngque3.setEditable(false); textField_zhrngque3.setBounds(535, 163, 66, 21); panel.add(textField_zhrngque3); textField_zhrngque3.setColumns(20); textField_zhengque4 = new JTextField(); textField_zhengque4.setEditable(false); textField_zhengque4.setBounds(535, 206, 66, 21); panel.add(textField_zhengque4); textField_zhengque4.setColumns(20); textField_zhengque5 = new JTextField(); textField_zhengque5.setEditable(false); textField_zhengque5.setEnabled(true); textField_zhengque5.setText(""); textField_zhengque5.setBounds(535, 249, 66, 21); panel.add(textField_zhengque5); textField_zhengque5.setColumns(20); textField_shijian1 = new JTextField(); textField_shijian1.setEditable(false); textField_shijian1.setBounds(621, 77, 66, 21); panel.add(textField_shijian1); textField_shijian1.setColumns(30); textField_shijian2 = new JTextField(); textField_shijian2.setEnabled(true); textField_shijian2.setEditable(false); textField_shijian2.setText(""); textField_shijian2.setBounds(621, 120, 66, 21); panel.add(textField_shijian2); textField_shijian2.setColumns(30); textField_shijian3 = new JTextField(); textField_shijian3.setEnabled(true); textField_shijian3.setEditable(false); textField_shijian3.setText(""); textField_shijian3.setBounds(621, 163, 66, 21); panel.add(textField_shijian3); textField_shijian3.setColumns(30); textField_shijian4 = new JTextField(); textField_shijian4.setEnabled(true); textField_shijian4.setEditable(false); textField_shijian4.setText(""); textField_shijian4.setBounds(621, 206, 66, 21); panel.add(textField_shijian4); textField_shijian4.setColumns(30); textField_shijian5 = new JTextField(); textField_shijian5.setEnabled(true); textField_shijian5.setEditable(false); textField_shijian5.setText(""); textField_shijian5.setBounds(621, 249, 66, 21); panel.add(textField_shijian5); textField_shijian5.setColumns(30); textField_zq = new JTextField(); textField_zq.setEditable(false); textField_zq.setBounds(10, 340, 66, 21); panel.add(textField_zq); textField_zq.setColumns(20); textField_zql = new JTextField(); textField_zql.setEnabled(true); textField_zql.setEditable(false); textField_zql.setText(""); textField_zql.setBounds(96, 340, 66, 21); panel.add(textField_zql); textField_zql.setColumns(20); textField_allshijian = new JTextField(); textField_allshijian.setEditable(false); textField_allshijian.setBounds(621, 340, 66, 21); panel.add(textField_allshijian); textField_allshijian.setColumns(30); JButton button_daan = new JButton("答案"); button_daan.setEnabled(false); button_daan.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); button_daan.setBounds(351, 391, 81, 23); panel.add(button_daan); btnNewButton_queding = new JButton("确定"); btnNewButton_queding.setEnabled(false); btnNewButton_queding.setBounds(471, 391, 81, 23); panel.add(btnNewButton_queding); btnNewButton_jixv = new JButton("继续答题"); btnNewButton_jixv.setEnabled(false); btnNewButton_jixv.setBounds(590, 391, 97, 23); panel.add(btnNewButton_jixv); label = new JLabel("\u9898\u76EE\u6570\u91CF"); label.setForeground(Color.GRAY); label.setBackground(Color.RED); label.setBounds(95, 13, 54, 15); panel.add(label); setVisible(true); //将窗口设置为可视 setResizable(false); setAlwaysOnTop(true);//设置此窗口永远为最上方 是window的方法 setLocationRelativeTo(null); getContentPane().setLayout(null); } public void setx(String x) { this.x=x; } public String getx() { return x; } public void actionPerformed(ActionEvent e) { if(e.getSource()==List)//职务 { //emp[i]=new employee(); if(List.getSelectedItem().equals("随机")) { //System.out.print("@@@@@@@@@@@@@@@@@@@@"); Random z=new Random(); //int c=z.nextInt(4)+1; //System.out.print(c); x=String.valueOf(z.nextInt(4)+1); new test2(x); } else { x=(String) List.getSelectedItem(); //System.out.print(x); //zanshi k=new zanshi(); //k.setx((String) List.getSelectedItem()); //System.out.print(k.getx()); //System.out.print(x); //List.requestFocusInWindow(); new test2(x); } setVisible(false); //textField_zhengshi1.setText(a[0]); } } /*public static void main(String[] args) { // TODO Auto-generated method stub new newFrame(); }*/ //public static void main(String[]args) //{ //Test t1=new Test(); //t1.start(); //newFrame1 b=new newFrame1(); //b.setVisible(false); //将窗口设置为可视 //zanshi k=new zanshi(); //System.out.print(b.getx()); //System.out.print(b.getx()); /*do { zanshi k=new zanshi(); //System.out.print("nim!!!"+k.getx()); for(int x1=0;x1<Integer.parseInt(k.getx());x1++) { test2 a=new test2(); } //Test t=new Test();t.start(); System.out.print("continue?(Y or N)"); Scanner in=new Scanner(System.in); String x=in.nextLine(); if(x.equals("N") || x.equals("n")) break; else if(x.equals("Y") || x.equals("Y")) System.out.print("\n加油加油噢~\n"); else { System.out.print("小朋友,请不要捣乱噢,为了惩罚你,再做一题~\n\n"); } //try{ //10000毫秒以后结束线程 //Thread.sleep(5000); //}catch(InterruptedException e1){ //e1.printStackTrace(); //} //结束线程 // t.stop(); }while(true); //开始线程 */ //} }
package size; //import test2; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.Random; import java.util.Scanner; public class newFrame2 extends JFrame implements ActionListener{ public JButton btnNewButton_1,btnNewButton; public JComboBox List; public JTextField textField_2; public JTextField textField_zhengshi1; public JTextField textField_daan1; public JTextField textField_zhenshi2; public JTextField textField_daan2; public JTextField textField_zhengshi3; public JTextField textField_daan; public JTextField textField_zhengshi4; public JTextField textField; public JTextField textField_zhengshi5; public JTextField textField_daan5; public JTextField textField_duicuo1; public JTextField textField_duicuo2; public JTextField textField_duicuo3; public JTextField textField_duicuo4; public JTextField textField_duicuo5; public JTextField textField_zhengque1; public JTextField textField_zhengque2; public JTextField textField_zhrngque3; public JTextField textField_zhengque4; public JTextField textField_zhengque5; public JTextField textField_shijian1; public JTextField textField_shijian2; public JTextField textField_shijian3; public JTextField textField_shijian4; public JTextField textField_shijian5; public JTextField textField_zq; public JTextField textField_zql; public JTextField textField_allshijian; public JButton btnNewButton_queding; public JButton btnNewButton_jixv; public String x; private JLabel label; public newFrame2() { super("阶乘运算"); getContentPane().setLayout(null); JPanel panel = new JPanel(); panel.setForeground(Color.GRAY); setSize(725, 463); panel.setBounds(0, 0, 719, 435); getContentPane().add(panel); panel.setLayout(null); String[] zw={"随机","1","2","3","4","5"}; List=new JComboBox(zw); List.addActionListener(this); List.setFont(new Font("宋体", Font.PLAIN, 13)); List.setBounds(10, 10, 75, 21); panel.add(List); textField_zhengshi1 = new JTextField(); textField_zhengshi1.setEditable(false); textField_zhengshi1.setBounds(10, 77, 358, 21); panel.add(textField_zhengshi1); textField_zhengshi1.setColumns(50); textField_zhengshi1.addActionListener(this); textField_daan1 = new JTextField(); textField_daan1.setEditable(false); textField_daan1.setBounds(402, 77, 66, 21); panel.add(textField_daan1); textField_daan1.setColumns(20); textField_zhenshi2 = new JTextField(); textField_zhenshi2.setEditable(false); textField_zhenshi2.setBounds(10, 120, 358, 21); panel.add(textField_zhenshi2); textField_zhenshi2.setColumns(50); textField_daan2 = new JTextField(); textField_daan2.setEditable(false); textField_daan2.setBounds(402, 120, 66, 21); panel.add(textField_daan2); textField_daan2.setColumns(20); textField_zhengshi3 = new JTextField(); textField_zhengshi3.setEditable(false); textField_zhengshi3.setBounds(10, 163, 358, 21); panel.add(textField_zhengshi3); textField_zhengshi3.setColumns(50); textField_daan = new JTextField(); textField_daan.setEditable(false); textField_daan.setBounds(402, 163, 66, 21); panel.add(textField_daan); textField_daan.setColumns(20); textField_zhengshi4 = new JTextField(); textField_zhengshi4.setEditable(false); textField_zhengshi4.setBounds(10, 206, 358, 21); panel.add(textField_zhengshi4); textField_zhengshi4.setColumns(50); textField = new JTextField(); textField.setEditable(false); textField.setText(""); textField.setBounds(402, 206, 66, 21); panel.add(textField); textField.setColumns(10); textField_zhengshi5 = new JTextField(); textField_zhengshi5.setEditable(false); textField_zhengshi5.setBounds(10, 249, 358, 21); panel.add(textField_zhengshi5); textField_zhengshi5.setColumns(50); textField_daan5 = new JTextField(); textField_daan5.setEditable(false); textField_daan5.setBounds(402, 249, 66, 21); panel.add(textField_daan5); textField_daan5.setColumns(20); textField_duicuo1 = new JTextField(); textField_duicuo1.setEditable(false); textField_duicuo1.setBounds(488, 77, 37, 21); panel.add(textField_duicuo1); textField_duicuo1.setColumns(10); textField_duicuo2 = new JTextField(); textField_duicuo2.setEditable(false); textField_duicuo2.setEnabled(true); textField_duicuo2.setText(""); textField_duicuo2.setBounds(488, 120, 37, 21); panel.add(textField_duicuo2); textField_duicuo2.setColumns(10); textField_duicuo3 = new JTextField(); textField_duicuo3.setEnabled(true); textField_duicuo3.setEditable(false); textField_duicuo3.setText(""); textField_duicuo3.setBounds(488, 163, 37, 21); panel.add(textField_duicuo3); textField_duicuo3.setColumns(10); textField_duicuo4 = new JTextField(); textField_duicuo4.setEnabled(true); textField_duicuo4.setEditable(false); textField_duicuo4.setText(""); textField_duicuo4.setBounds(488, 206, 37, 21); panel.add(textField_duicuo4); textField_duicuo4.setColumns(10); textField_duicuo5 = new JTextField(); textField_duicuo5.setEnabled(true); textField_duicuo5.setEditable(false); textField_duicuo5.setText(""); textField_duicuo5.setBounds(488, 249, 37, 21); panel.add(textField_duicuo5); textField_duicuo5.setColumns(10); textField_zhengque1 = new JTextField(); textField_zhengque1.setEditable(false); textField_zhengque1.setBounds(535, 77, 66, 21); panel.add(textField_zhengque1); textField_zhengque1.setColumns(20); textField_zhengque2 = new JTextField(); textField_zhengque2.setEditable(false); textField_zhengque2.setEnabled(true); textField_zhengque2.setText(""); textField_zhengque2.setBounds(535, 120, 66, 21); panel.add(textField_zhengque2); textField_zhengque2.setColumns(20); textField_zhrngque3 = new JTextField(); textField_zhrngque3.setEditable(false); textField_zhrngque3.setBounds(535, 163, 66, 21); panel.add(textField_zhrngque3); textField_zhrngque3.setColumns(20); textField_zhengque4 = new JTextField(); textField_zhengque4.setEditable(false); textField_zhengque4.setBounds(535, 206, 66, 21); panel.add(textField_zhengque4); textField_zhengque4.setColumns(20); textField_zhengque5 = new JTextField(); textField_zhengque5.setEditable(false); textField_zhengque5.setEnabled(true); textField_zhengque5.setText(""); textField_zhengque5.setBounds(535, 249, 66, 21); panel.add(textField_zhengque5); textField_zhengque5.setColumns(20); textField_shijian1 = new JTextField(); textField_shijian1.setEditable(false); textField_shijian1.setBounds(621, 77, 66, 21); panel.add(textField_shijian1); textField_shijian1.setColumns(30); textField_shijian2 = new JTextField(); textField_shijian2.setEnabled(true); textField_shijian2.setEditable(false); textField_shijian2.setText(""); textField_shijian2.setBounds(621, 120, 66, 21); panel.add(textField_shijian2); textField_shijian2.setColumns(30); textField_shijian3 = new JTextField(); textField_shijian3.setEnabled(true); textField_shijian3.setEditable(false); textField_shijian3.setText(""); textField_shijian3.setBounds(621, 163, 66, 21); panel.add(textField_shijian3); textField_shijian3.setColumns(30); textField_shijian4 = new JTextField(); textField_shijian4.setEnabled(true); textField_shijian4.setEditable(false); textField_shijian4.setText(""); textField_shijian4.setBounds(621, 206, 66, 21); panel.add(textField_shijian4); textField_shijian4.setColumns(30); textField_shijian5 = new JTextField(); textField_shijian5.setEnabled(true); textField_shijian5.setEditable(false); textField_shijian5.setText(""); textField_shijian5.setBounds(621, 249, 66, 21); panel.add(textField_shijian5); textField_shijian5.setColumns(30); textField_zq = new JTextField(); textField_zq.setEditable(false); textField_zq.setBounds(10, 340, 66, 21); panel.add(textField_zq); textField_zq.setColumns(20); textField_zql = new JTextField(); textField_zql.setEnabled(true); textField_zql.setEditable(false); textField_zql.setText(""); textField_zql.setBounds(96, 340, 66, 21); panel.add(textField_zql); textField_zql.setColumns(20); textField_allshijian = new JTextField(); textField_allshijian.setEditable(false); textField_allshijian.setBounds(621, 340, 66, 21); panel.add(textField_allshijian); textField_allshijian.setColumns(30); JButton button_daan = new JButton("答案"); button_daan.setEnabled(false); button_daan.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); button_daan.setBounds(351, 391, 81, 23); panel.add(button_daan); btnNewButton_queding = new JButton("确定"); btnNewButton_queding.setEnabled(false); btnNewButton_queding.setBounds(471, 391, 81, 23); panel.add(btnNewButton_queding); btnNewButton_jixv = new JButton("继续答题"); btnNewButton_jixv.setEnabled(false); btnNewButton_jixv.setBounds(590, 391, 97, 23); panel.add(btnNewButton_jixv); label = new JLabel("\u9898\u76EE\u6570\u91CF"); label.setForeground(Color.GRAY); label.setBackground(Color.RED); label.setBounds(95, 13, 54, 15); panel.add(label); setVisible(true); //将窗口设置为可视 setResizable(false); setAlwaysOnTop(true);//设置此窗口永远为最上方 是window的方法 setLocationRelativeTo(null); getContentPane().setLayout(null); } public void setx(String x) { this.x=x; } public String getx() { return x; } public void actionPerformed(ActionEvent e) { if(e.getSource()==List)//职务 { //emp[i]=new employee(); if(List.getSelectedItem().equals("随机")) { //System.out.print("@@@@@@@@@@@@@@@@@@@@"); Random z=new Random(); //int c=z.nextInt(4)+1; //System.out.print(c); x=String.valueOf(z.nextInt(4)+1); new test1(x); } else { x=(String) List.getSelectedItem(); //System.out.print(x); //zanshi k=new zanshi(); //k.setx((String) List.getSelectedItem()); //System.out.print(k.getx()); //System.out.print(x); //List.requestFocusInWindow(); new test1(x); } setVisible(false); //textField_zhengshi1.setText(a[0]); } } /*public static void main(String[] args) { // TODO Auto-generated method stub new newFrame(); }*/ //public static void main(String[]args) //{ //Test t1=new Test(); //t1.start(); //newFrame2 b=new newFrame2(); //b.setVisible(false); //将窗口设置为可视 //zanshi k=new zanshi(); //System.out.print(b.getx()); //System.out.print(b.getx()); /*do { zanshi k=new zanshi(); //System.out.print("nim!!!"+k.getx()); for(int x1=0;x1<Integer.parseInt(k.getx());x1++) { test2 a=new test2(); } //Test t=new Test();t.start(); System.out.print("continue?(Y or N)"); Scanner in=new Scanner(System.in); String x=in.nextLine(); if(x.equals("N") || x.equals("n")) break; else if(x.equals("Y") || x.equals("Y")) System.out.print("\n加油加油噢~\n"); else { System.out.print("小朋友,请不要捣乱噢,为了惩罚你,再做一题~\n\n"); } //try{ //10000毫秒以后结束线程 //Thread.sleep(5000); //}catch(InterruptedException e1){ //e1.printStackTrace(); //} //结束线程 // t.stop(); }while(true); //开始线程 */ //} }
package size; //import test2; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.Random; import java.util.Scanner; public class newFrame3 extends JFrame implements ActionListener{ public JButton btnNewButton_1,btnNewButton; public JComboBox List; public JTextField textField_2; public JTextField textField_zhengshi1; public JTextField textField_daan1; public JTextField textField_zhengshi2; public JTextField textField_daan2; public JTextField textField_zhengshi3; public JTextField textField_daan3; public JTextField textField_zhengshi4; public JTextField textField_daan4; public JTextField textField_zhengshi5; public JTextField textField_daan5; public JTextField textField_duicuo1; public JTextField textField_duicuo2; public JTextField textField_duicuo3; public JTextField textField_duicuo4; public JTextField textField_duicuo5; public JTextField textField_zhengque1; public JTextField textField_zhengque2; public JTextField textField_zhengque3; public JTextField textField_zhengque4; public JTextField textField_zhengque5; public JTextField textField_shijian1; public JTextField textField_shijian2; public JTextField textField_shijian3; public JTextField textField_shijian4; public JTextField textField_shijian5; public JTextField textField_zq; public JTextField textField_zql; public JTextField textField_allshijian; public JButton button_daan; public JButton btnNewButton_queding; public JButton btnNewButton_jixv; public String x; public String []c=new String [10]; public Test t; public static int num=0; public static int num1=0; public long begin,end,sum; private JLabel label_4; private JLabel label_5; private JLabel label_6; private JLabel label_7; public newFrame3(String a[]) { super("阶乘运算"); c=a; getContentPane().setLayout(null); JPanel panel = new JPanel(); panel.setForeground(new Color(255, 0, 102)); setSize(725, 463); panel.setBounds(0, 0, 719, 435); getContentPane().add(panel); panel.setLayout(null); String[] zw={"随机","1","2","3","4","5"}; List=new JComboBox(zw); List.setEnabled(false); List.addActionListener(this); List.setFont(new Font("宋体", Font.PLAIN, 13)); List.setBounds(10, 10, 75, 21); panel.add(List); textField_zhengshi1 = new JTextField(); textField_zhengshi1.setEditable(false); textField_zhengshi1.setBounds(10, 77, 240, 21); panel.add(textField_zhengshi1); textField_zhengshi1.setColumns(50); textField_zhengshi1.setText(a[0]); textField_zhengshi1.addActionListener(this); textField_daan1 = new JTextField(); textField_daan1.setBounds(286, 77, 102, 21); panel.add(textField_daan1); textField_daan1.addActionListener(this); textField_daan1.setColumns(20); textField_zhengshi2 = new JTextField(); textField_zhengshi2.setEditable(false); textField_zhengshi2.setBounds(10, 120, 240, 21); panel.add(textField_zhengshi2); textField_zhengshi2.setText(a[2]); textField_zhengshi2.setColumns(50); textField_daan2 = new JTextField(); textField_daan2.setBounds(286, 120, 102, 21); panel.add(textField_daan2); textField_daan2.addActionListener(this); textField_daan2.setColumns(20); textField_zhengshi3 = new JTextField(); textField_zhengshi3.setEditable(false); textField_zhengshi3.setBounds(10, 163, 240, 21); panel.add(textField_zhengshi3); textField_zhengshi3.setText(a[4]); textField_zhengshi3.setColumns(50); textField_daan3 = new JTextField(); textField_daan3.setBounds(286, 163, 102, 21); panel.add(textField_daan3); textField_daan3.addActionListener(this); textField_daan3.setColumns(20); textField_zhengshi4 = new JTextField(); textField_zhengshi4.setEditable(false); textField_zhengshi4.setBounds(10, 206, 240, 21); panel.add(textField_zhengshi4); textField_zhengshi4.setText(a[6]); textField_zhengshi4.setColumns(50); textField_daan4 = new JTextField(); textField_daan4.setText(""); textField_daan4.setBounds(286, 206, 102, 21); panel.add(textField_daan4); textField_daan4.addActionListener(this); textField_daan4.setColumns(10); textField_zhengshi5 = new JTextField(); textField_zhengshi5.setEditable(false); textField_zhengshi5.setBounds(10, 249, 240, 21); panel.add(textField_zhengshi5); textField_zhengshi5.setText(a[8]); textField_zhengshi5.setColumns(50); textField_daan5 = new JTextField(); textField_daan5.setBounds(286, 249, 102, 21); panel.add(textField_daan5); textField_daan5.addActionListener(this); textField_daan5.setColumns(20); textField_duicuo1 = new JTextField(); textField_duicuo1.setForeground(Color.RED); textField_duicuo1.setBackground(Color.WHITE); textField_duicuo1.setBounds(422, 77, 37, 21); panel.add(textField_duicuo1); textField_duicuo1.setColumns(10); textField_duicuo2 = new JTextField(); textField_duicuo2.setForeground(Color.RED); textField_duicuo2.setEnabled(true); textField_duicuo2.setText(""); textField_duicuo2.setBounds(422, 120, 37, 21); panel.add(textField_duicuo2); textField_duicuo2.setColumns(10); textField_duicuo3 = new JTextField(); textField_duicuo3.setForeground(Color.RED); textField_duicuo3.setEnabled(true); textField_duicuo3.setText(""); textField_duicuo3.setBounds(422, 163, 37, 21); panel.add(textField_duicuo3); textField_duicuo3.setColumns(10); textField_duicuo4 = new JTextField(); textField_duicuo4.setForeground(Color.RED); textField_duicuo4.setEnabled(true); textField_duicuo4.setText(""); textField_duicuo4.setBounds(422, 206, 37, 21); panel.add(textField_duicuo4); textField_duicuo4.setColumns(10); textField_duicuo5 = new JTextField(); textField_duicuo5.setForeground(Color.RED); textField_duicuo5.setEnabled(true); textField_duicuo5.setText(""); textField_duicuo5.setBounds(422, 249, 37, 21); panel.add(textField_duicuo5); textField_duicuo5.setColumns(10); textField_zhengque1 = new JTextField(); textField_zhengque1.setForeground(Color.BLUE); textField_zhengque1.setEditable(false); textField_zhengque1.setBounds(499, 77, 102, 21); panel.add(textField_zhengque1); textField_zhengque1.setColumns(20); textField_zhengque2 = new JTextField(); textField_zhengque2.setForeground(Color.BLUE); textField_zhengque2.setEditable(false); textField_zhengque2.setEnabled(true); textField_zhengque2.setText(""); textField_zhengque2.setBounds(499, 120, 102, 21); panel.add(textField_zhengque2); textField_zhengque2.setColumns(20); textField_zhengque3 = new JTextField(); textField_zhengque3.setForeground(Color.BLUE); textField_zhengque3.setEditable(false); textField_zhengque3.setBounds(499, 163, 102, 21); panel.add(textField_zhengque3); textField_zhengque3.setColumns(20); textField_zhengque4 = new JTextField(); textField_zhengque4.setForeground(Color.BLUE); textField_zhengque4.setEditable(false); textField_zhengque4.setBounds(499, 206, 102, 21); panel.add(textField_zhengque4); textField_zhengque4.setColumns(20); textField_zhengque5 = new JTextField(); textField_zhengque5.setForeground(Color.BLUE); textField_zhengque5.setEditable(false); textField_zhengque5.setEnabled(true); textField_zhengque5.setText(""); textField_zhengque5.setBounds(499, 249, 102, 21); panel.add(textField_zhengque5); textField_zhengque5.setColumns(20); textField_shijian1 = new JTextField(); textField_shijian1.setForeground(new Color(255, 0, 102)); textField_shijian1.setEditable(false); textField_shijian1.setBounds(621, 77, 66, 21); panel.add(textField_shijian1); textField_shijian1.setColumns(30); textField_shijian2 = new JTextField(); textField_shijian2.setForeground(new Color(255, 0, 102)); textField_shijian2.setEnabled(true); textField_shijian2.setEditable(false); textField_shijian2.setText(""); textField_shijian2.setBounds(621, 120, 66, 21); panel.add(textField_shijian2); textField_shijian2.setColumns(30); textField_shijian3 = new JTextField(); textField_shijian3.setForeground(new Color(255, 0, 102)); textField_shijian3.setEnabled(true); textField_shijian3.setEditable(false); textField_shijian3.setText(""); textField_shijian3.setBounds(621, 163, 66, 21); panel.add(textField_shijian3); textField_shijian3.setColumns(30); textField_shijian4 = new JTextField(); textField_shijian4.setForeground(new Color(255, 0, 102)); textField_shijian4.setEnabled(true); textField_shijian4.setEditable(false); textField_shijian4.setText(""); textField_shijian4.setBounds(621, 206, 66, 21); panel.add(textField_shijian4); textField_shijian4.setColumns(30); textField_shijian5 = new JTextField(); textField_shijian5.setForeground(new Color(255, 0, 102)); textField_shijian5.setEnabled(true); textField_shijian5.setEditable(false); textField_shijian5.setText(""); textField_shijian5.setBounds(621, 249, 66, 21); panel.add(textField_shijian5); textField_shijian5.setColumns(30); textField_zq = new JTextField(); textField_zq.setEditable(false); textField_zq.setBounds(10, 340, 66, 21); panel.add(textField_zq); textField_zq.setColumns(20); textField_zql = new JTextField(); textField_zql.setEnabled(true); textField_zql.setEditable(false); textField_zql.setText(""); textField_zql.setBounds(96, 340, 66, 21); panel.add(textField_zql); textField_zql.setColumns(20); textField_allshijian = new JTextField(); textField_allshijian.setEditable(false); textField_allshijian.setBounds(621, 340, 66, 21); panel.add(textField_allshijian); textField_allshijian.setColumns(30); button_daan = new JButton("答案"); button_daan.addActionListener(this); button_daan.setBounds(351, 391, 81, 23); panel.add(button_daan); btnNewButton_queding = new JButton("确定"); btnNewButton_queding.setBounds(471, 391, 81, 23); btnNewButton_queding.addActionListener(this); panel.add(btnNewButton_queding); btnNewButton_jixv = new JButton("继续答题"); btnNewButton_jixv.setBounds(590, 391, 97, 23); btnNewButton_jixv.addActionListener(this); panel.add(btnNewButton_jixv); JLabel label = new JLabel("\u9898\u76EE"); label.setBounds(10, 52, 54, 15); panel.add(label); JLabel label_1 = new JLabel("\u8F93\u5165\u7B54\u6848"); label_1.setBounds(286, 52, 54, 15); panel.add(label_1); JLabel label_2 = new JLabel("\u5224\u65AD"); label_2.setBounds(422, 52, 54, 15); panel.add(label_2); JLabel label_3 = new JLabel("\u53C2\u8003\u7B54\u6848"); label_3.setBounds(499, 52, 54, 15); panel.add(label_3); label_4 = new JLabel("\u7B54\u9898\u65F6\u95F4"); label_4.setBounds(621, 52, 54, 15); panel.add(label_4); label_5 = new JLabel("\u603B\u65F6\u95F4"); label_5.setBounds(621, 315, 54, 15); panel.add(label_5); label_6 = new JLabel("\u6B63\u786E\u9898\u6570"); label_6.setForeground(Color.RED); label_6.setBounds(10, 315, 54, 15); panel.add(label_6); label_7 = new JLabel("\u6B63\u786E\u7387"); label_7.setForeground(Color.RED); label_7.setBounds(96, 315, 54, 15); panel.add(label_7); Test t=new Test(); // t.start(); begin=System.currentTimeMillis(); setVisible(true); //将窗口设置为可视 setResizable(false); setAlwaysOnTop(true);//设置此窗口永远为最上方 是window的方法 setLocationRelativeTo(null); getContentPane().setLayout(null); } public void setx(String x) { this.x=x; } public String getx() { return x; } public void actionPerformed(ActionEvent e) { if(e.getSource()==button_daan) { textField_zhengque1.setText(c[1]); textField_zhengque2.setText(c[3]); textField_zhengque3.setText(c[5]); textField_zhengque4.setText(c[7]); textField_zhengque5.setText(c[9]); //emp[i]=new employee(); //x=(String) List.getSelectedItem(); //System.out.print(x); //zanshi k=new zanshi(); //k.setx((String) List.getSelectedItem()); //System.out.print(k.getx()); //System.out.print(x); //List.requestFocusInWindow(); //new test2(x); //newFrame b=new newFrame(""); //textField_zhengshi1.setText(a[0]); } //try{ //10000毫秒以后结束线程 //Thread.sleep(5000); else if(e.getSource()==textField_daan1)//职务 { if(textField_daan1.getText().equals(c[1])) { textField_duicuo1.setText("√"); //t.stop(); //end=System.currentTimeMillis(); sum=(System.currentTimeMillis()-begin)/1000; textField_shijian1.setText(String.valueOf(sum)+"s"); textField_daan2.requestFocusInWindow(); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } else { textField_duicuo1.setText("×"); sum=(System.currentTimeMillis()-begin)/1000; textField_shijian1.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian1.setText(String.valueOf(t.time)); //t.stop();textField_daan2.requestFocusInWindow(); textField_daan2.requestFocusInWindow(); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } else if(e.getSource()==textField_daan2)//职务 { if(textField_daan2.getText().equals(c[3])) { textField_duicuo2.setText("√"); sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian2.setText(String.valueOf(sum)+"s"); //textField_shijian2.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } else { if(c[3].equals("")) { textField_duicuo2.setText("none"); } else { textField_duicuo2.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian2.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian2.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } textField_daan3.requestFocusInWindow(); } else if(e.getSource()==textField_daan3)//职务 { Test t=new Test(); t.start(); if(textField_daan3.getText().equals(c[5])) { textField_duicuo3.setText("√"); sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian3.setText(String.valueOf(sum)+"s"); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); //textField_shijian3.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); } else { if(c[5].equals("")) { textField_duicuo3.setText("none"); } else { textField_duicuo3.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian3.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian3.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } textField_daan4.requestFocusInWindow(); } else if(e.getSource()==textField_daan4)//职务 { if(textField_daan4.getText().equals(c[7])) { textField_duicuo4.setText("√"); sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian4.setText(String.valueOf(sum)+"s"); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); //textField_shijian4.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); } else { if(c[7].equals("")) { textField_duicuo4.setText("none"); } else { textField_duicuo4.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian4.setText(String.valueOf(sum)+"s"); num1++; //textField_shijian4.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } textField_daan5.requestFocusInWindow(); } else if(e.getSource()==textField_daan5)//职务 { if(textField_daan5.getText().equals(c[9])) { sum=(System.currentTimeMillis()-begin)/1000-sum; //sum=System.currentTimeMillis()/1000-sum; textField_shijian5.setText(String.valueOf(sum)+"s"); //textField_shijian5.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); textField_duicuo5.setText("√"); num++;num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } else { if(c[9].equals("")) { textField_duicuo5.setText("none"); } else { textField_duicuo5.setText("×"); //sum=System.currentTimeMillis()/1000-sum; sum=(System.currentTimeMillis()-begin)/1000-sum; textField_shijian5.setText(String.valueOf(sum)+"s"); //textField_shijian5.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)); num1++; textField_zq.setText(String.valueOf(num)); float x=(float)num/num1*100; textField_zql.setText(String.valueOf(x)); } } btnNewButton_queding.requestFocusInWindow(); } //} //} //catch(InterruptedException e1) //{ //e1.printStackTrace(); //} else if(e.getSource()==btnNewButton_queding)//职务 { //t.stop(); textField_allshijian.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)+"s"); } else if(e.getSource()==btnNewButton_jixv)//职务 { //t.stop(); //textField_allshijian.setText(String.valueOf((System.currentTimeMillis()-begin)/1000)+"s"); setVisible(false); new newFrame1(); } /*if(e.getSource()==button_daan)//职务 { //x=(String) List.getSelectedItem(); new test2(x); }*/ /*if(e.getSource()==button_daan)//职务 { //x=(String) List.getSelectedItem(); new test2(x); } */ } }
package size; import java.text.SimpleDateFormat; import java.util.*; public class Test implements Runnable { //定义一个线程 Thread thread; //用于停止线程的标志 private boolean flag=true; public long time,beginTime; public Test(){ thread=new Thread(this); } //因为该类实现了Runnable,就必须有run方法,当线程启动时,会调用这个run方法 public void run(){ //获得当前的时间,毫秒为单位 //long beginTime=System.currentTimeMillis(); beginTime=System.currentTimeMillis(); //定义已过去的时间 time=0; while(flag){ //这里写实现计时的代码 //在这里,获得已过去的时间 time=(System.currentTimeMillis()-beginTime)/1000; // System.out.println("已过"+time+"毫秒"); //System.out.println("显示当前时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis())); //System.out.print(time); //暂停线程1秒钟,不暂停的话可以把下面代码去掉 try{ Thread.sleep(1000); }catch(InterruptedException e1){ e1.printStackTrace(); } /*if(time==7) { try { thread.wait(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); //System.out.print("tingxia lai le"); } }*/ } } //这里是启动线程的方法,也就是启动线程 public void start(){ thread.start(); } //这里是暂停的方法,暂停线程 public void Pause(){ try{ thread.wait(); }catch(InterruptedException e){ e.printStackTrace(); } } //这里是继续的方法,唤醒线程 public void Resume(){ thread.notifyAll(); } //停止线程 public void stop(){ //把flag设成false,则在run中的while循环就会停止循环 flag=false; } public static void main(String []args){ //用于测试 Test t=new Test(); Test t1=new Test(); //开始线程 t.start(); t1.start(); //System.out.print(t.time); //System.out.println("显示当前时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis())); try{ //10000毫秒以后结束线程 Thread.sleep(5000); }catch(InterruptedException e1){ e1.printStackTrace(); } //结束线程 t.stop(); } }
package size; import java.math.*; import java.text.DecimalFormat; import java.util.Random; public class test1 { public int i,j=1,l; public BigDecimal k= new BigDecimal(1); //DecimalFormat df=new DecimalFormat("#,##"); //String result=df.format(dValue) String []v=new String [10]; test1(String a) { for(l=0;l<10;l++) { v[l]=""; } l=0; for(int f=0;f<Integer.parseInt(a);f++) { BigDecimal.valueOf(j); Random z=new Random(); i=z.nextInt(9)+1; v[l]=String.valueOf(i); v[l]+="!"; System.out.print(i+"!="); do { k=k.multiply(BigDecimal.valueOf(j)); j++; }while(j<=i); System.out.print(k+"\n");//df.format(k) l++;v[l]=String.valueOf(k);l++; k=new BigDecimal(1); j=1; } new newFrame3(v); } /*public static void main(String[]args) { test1 a=new test1(""); }*/ }
package size; import java.util.Random; import java.util.Scanner; public class test2 { public int sighfh,fuhaosl; public float sighsz1,sighsz2,answer2,sum2=0,sum3=0; public float []sighsz=new float[30]; public String []fuhaoq={"+","-","*","/"}; public String []fuhao=new String[30]; public String fuhao2,answer1,s; public String []zhengshi=new String[200]; public String []first=new String[100]; public String []second=new String[100]; public String []three=new String[100]; public String temp1="null"; public int i=0,jia=0,jian=0,q=0,x=0,chen=0,chu=0,temp2,j=0,c,op=0; public float sum=0; public test2(String x) { String[]xx=new String[10]; for(c=0;c<10;c++) xx[c]=""; c=0; for(int x1=0;x1<Integer.parseInt(x);x1++) { Random z=new Random(); sighsz1=z.nextFloat()*10; int k=0; sighsz1=(float)(Math.round(sighsz1*100))/100; zhengshi[k]=String.valueOf(sighsz1); fuhaosl=z.nextInt(3)+1; //fuhaosl=4; //System.out.printf("fuhaosl=%d\n",fuhaosl); for(i=1;i<=fuhaosl;i++) { sighfh=z.nextInt(4); switch(sighfh) { case 0:zhengshi[k]+="\t+\t";sighsz[k]=z.nextFloat()*100;sighsz[k]=(float)(Math.round(sighsz[k]*100))/100; zhengshi[k]+=String.valueOf(sighsz[k]); jia++; break; case 1:zhengshi[k]+="\t-\t"; sighsz[k]=z.nextFloat()*100;sighsz[k]=(float)(Math.round(sighsz[k]*100))/100; zhengshi[k]+=String.valueOf(sighsz[k]); jian++; break; case 2:zhengshi[k]+="\t*\t"; sighsz[k]=z.nextFloat()*100;sighsz[k]=(float)(Math.round(sighsz[k]*100))/100; zhengshi[k]+=String.valueOf(sighsz[k]); chen++; break; case 3:zhengshi[k]+="\t/\t"; sighsz[k]=z.nextFloat()*100;sighsz[k]=(float)(Math.round(sighsz[k]*100))/100; zhengshi[k]+=String.valueOf(sighsz[k]); chu++; break; } } zhengshi[k]+="\t=\t"; //System.out.printf("%s",zhengshi[k]); String temp=""; //zhengshi[k]="1.1\t+\t2.2\t+\t3.3\t*\t5.5\t=\t"; System.out.printf("%s",zhengshi[k]); String []first=new String[200]; String []second=new String[200]; String[] zhengshi1=new String[200]; int q=0,i1=0,i2=0,j=0; i=0; temp = zhengshi[k]; //temp="\t=\t"; zhengshi1= temp.trim().split("\t"); while(op<=fuhaosl*2+1) { xx[c]+=zhengshi1[op]; //System.out.print(zhengshi1[op]); op++; } int y=0; while(zhengshi1[y]==null) { if(zhengshi1[y].equals("/")) { while(Float.parseFloat(zhengshi1[y+1])/1==0) { zhengshi1[y+1]=String.valueOf((float)(Math.round(sighsz1*100))/100); } } y++; } //System.out.print(zhengshi1[fuhaosl*2+1]); //zhengshi1[fuhaosl*2+1]="="; /*for(i=0;i<fuhaosl*2+1;i++) { second[i1]=zhengshi1[i]; i1++; }*/ i=0;j=0;k=0; while(zhengshi1[i].equals("=")==false ) { //System.out.print(i); try { if(Float.parseFloat(zhengshi1[i])>=0 && Float.parseFloat(zhengshi1[i])<=100) { first[j]=zhengshi1[i];//System.out.print(first[j]+"我进栈了,"+"现在的i是"+i); j++;i++; } } catch(NumberFormatException E) { if(second[0]==null) { second[k]=zhengshi1[i]; ///System.out.print(second[k]+"我进栈了,"+"现在的i是"+i); k++;i++; } else { if(compare(second[k-1],zhengshi1[i],first)) { if(first[k].equals(null)) { second[k]=zhengshi1[i];//System.out.print(second[k]+"我进栈了,"+"现在的i是"+i+"!!!!"); k++;i++; } else { if(second[k-1].equals("+")) { sum=Float.parseFloat(first[k-1])+Float.parseFloat(first[k]); //System.out.print(first[k-1]+","+first[k]+"我们出栈了,"+"现在的i是"+i); //System.out.print(second[k-1]+"我出栈了,"+"现在的i是"+i); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=zhengshi1[i]; //System.out.print("\n答案暂时是:"+sum+"\n"); j--;i++; } else if(second[k-1].equals("-")) { sum=Float.parseFloat(first[k-1])-Float.parseFloat(first[k]); //System.out.print(first[k-1]+","+first[k]+"我们出栈了,"+"现在的i是"+i); //System.out.print(second[k-1]+"我出栈了,"+"现在的i是"+i); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=zhengshi1[i]; //System.out.print("\n答案暂时是:"+sum+"\n"); j--;i++; } else if(second[k-1].equals("*")) { sum=Float.parseFloat(first[k-1])*Float.parseFloat(first[k]); //System.out.print(first[k-1]+","+first[k]+"我们出栈了,"+"现在的i是"+i); //System.out.print(second[k-1]+"我出栈了,"+"现在的i是"+i); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=zhengshi1[i]; //System.out.print("\n答案暂时是:"+sum+"\n"); j--;i++; } else if(second[k-1].equals("/")) { sum=Float.parseFloat(first[k-1])/Float.parseFloat(first[k]); //System.out.print(first[k-1]+","+first[k]+"我们出栈了,"+"现在的i是"+i); //System.out.print(second[k-1]+"我出栈了,"+"现在的i是"+i); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=zhengshi1[i]; //System.out.print("\n答案暂时是:"+sum+"\n"); j--;i++; } } } else { second[k]=zhengshi1[i]; //System.out.print(second[k]+","+second[k]+"我进栈了,"+"现在的i是"+i); i++;k++; } } } } /*if(second[0]==null) { System.out.print("答案为:"+sum); System.out.print("结束战斗!!!"); } else {*/ while(second[0]!=null) { //if(second[sign]!=null) //********************************************* //System.out.print("kkk===="+k); if(second[k-1].equals("+")) { sum=Float.parseFloat(first[k-1])+Float.parseFloat(first[k]); //System.out.print("\n答案暂时是:"+sum+"\n"); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=null; j--;k=k-1;i++; //if(second(1)!=null)//********************************************* //System.out.print("\n答案为:"+sum); } else if(second[k-1].equals("-")) { sum=Float.parseFloat(first[k-1])-Float.parseFloat(first[k]); //System.out.print("\n答案暂时是:"+sum+"\n"); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=null; j--;k=k-1;i++; //System.out.print("\n答案为:"+sum); } else if(second[k-1].equals("*")) { sum=Float.parseFloat(first[k-1])*Float.parseFloat(first[k]); //System.out.print("\n答案暂时是:"+sum+"\n"); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=null; j--;k=k-1;i++; //System.out.print("\n答案为:"+sum); } else if(second[k-1].equals("/")) { sum=Float.parseFloat(first[k-1])/Float.parseFloat(first[k]); //System.out.print("\n答案暂时是:"+sum+"\n"); first[k-1]=String.valueOf(sum);first[k]=null;second[k-1]=null; j--;k=k-1;i++; //System.out.print("\n答案为:"+sum); } } sum=(float)(Math.round(sum*100))/100; System.out.print("\n答案为:"+sum+"\t"); c++; xx[c]=String.valueOf(sum);c++;op=0; } int qw=0; new newFrame(xx); //a.textField_zhengshi1.setText(xx[0]); //a.textField_zhengshi2.setText(xx[2]); //a.textField_zhengshi3.setText(xx[4]); //a.textField_zhengshi4.setText(xx[6]); //a.textField_zhengshi5.setText(xx[8]); //a.actionPerformed(ActionEvent e) } /*first[j]=temp1; int c=0; System.out.print("\n"); for(i=0;i<=j;i++) { try { if(Float.parseFloat(first[i])>=0 && Float.parseFloat(first[i])<=100) { three[c]=first[i];c++; } } catch(NumberFormatException E) { if(c!=0) { System.out.print("!!!!"+c); System.out.print(i); if(first[i].equals("+")) { float result=Float.parseFloat(first[c-2])+Float.parseFloat(first[c-1]); three[c]=String.valueOf(result);i++;c=c-2; } else if(first[i].equals("-")) { float result=Float.parseFloat(first[c-2])-Float.parseFloat(first[c-1]); three[c]=String.valueOf(result); i++;c=c-2; } else if(first[i].equals("*")) { float result=Float.parseFloat(first[c-2])*Float.parseFloat(first[c-1]); three[c]=String.valueOf(result); i++;c=c-2; } else if(first[i].equals("/")) { float result=Float.parseFloat(first[c-2])/Float.parseFloat(first[c-1]); three[c]=String.valueOf(result); i++;c=c-2; } } } } for(i=0;i<=j/2;i++) { String xxx,xxy; xxx=first[i]; xxy=first[j-i]; first[i]=xxy; first[j-i]=xxx; } for(i=0;i<=j;i++) { System.out.print(first[i]+"\t"); }*/ boolean compare(String x1,String x2,String x3[]) //true 出栈,flase 进栈 { int i,j,k; if(x2.equals("+") || x2.equals("-")) return true; else { if(x1.equals("*") || x1.equals("/")) { return true; } else { return false; } } } /*public static void main(String[]args) { Scanner in=new Scanner(System.in); String b=String.valueOf(in.nextInt()); test2 a=new test2 (b); }*/ }
String xx=temp; ee.add(xx); } } catch (IOException e) { e.printStackTrace(); } String[] MM = new String[ee.size()]; for (int i = 0; i < ee.size(); i++) { MM[i] = ee.get(i); // 将动态数组对象内容赋值给EMPO数组; } return MM; } public void actionPerformed(ActionEvent e) { if(e.getSource()==btnNewButton) { File file = new File("ys.txt"); String[] xxx=reademp(file); String sign=textField.getText(); //jiemian tx=new jiemian(); for(w=0;w<xxx.length;w++) { System.out.print(xxx[w]); if(sign.equals(xxx[w])) { ww=1; new select(); } } if(ww==0) { JOptionPane.showMessageDialog(this,"未查找到该用户!" , "提示", JOptionPane.INFORMATION_MESSAGE); } } else if(e.getSource()==btnNewButton_1) { save(textField.getText()+'\n'); } } public static void main(String[]args) { new login(); } }