驾驶员:许佳豪
领航员:吴哲永 博客地址:http://www.cnblogs.com/dbssb/
在上次的结对编程作业中完成了:
四个扩展方向,此次作业添加了:
两个扩展方向。
主类:
1 package 四则运算; 2 3 public class Test { 4 5 public static void main(String[] args) { 6 7 MyFrame a=new MyFrame(); 8 9 } 10 11 }
窗体类:
1 package 四则运算; 2 3 import java.*; 4 import java.util.*; 5 6 import javax.swing.*; 7 8 import java.awt.*; 9 import java.awt.event.*; 10 import java.io.*; 11 12 public class MyFrame extends JFrame 13 { 14 JMenuBar M1=new JMenuBar(); 15 JMenu M2=new JMenu("更换颜色"); 16 JMenuItem M3=new JMenuItem("黄色"); 17 JMenuItem M4=new JMenuItem("橙色"); 18 JMenuItem M5=new JMenuItem("白色"); 19 JMenuItem M6=new JMenuItem("蓝色"); 20 JMenuItem M7=new JMenuItem("绿色"); 21 JLabel L1=new JLabel("请输入题数(最多不超过5题):"); 22 JLabel L2=new JLabel("第一题:"); 23 JLabel L3=new JLabel(" = "); 24 JLabel L4=new JLabel("第二题:"); 25 JLabel L5=new JLabel(" = "); 26 JLabel L6=new JLabel("第三题:"); 27 JLabel L7=new JLabel(" = "); 28 JLabel L8=new JLabel("第四题:"); 29 JLabel L9=new JLabel(" = "); 30 JLabel L10=new JLabel("第五题:"); 31 JLabel L11=new JLabel(" = "); 32 JLabel L12=new JLabel("欢迎您,尊敬的 "); 33 JLabel L13=new JLabel("用户"); 34 JLabel L14=new JLabel(""); 35 JLabel L15=new JLabel(" "); 36 JLabel L16=new JLabel(" "); 37 JLabel L17=new JLabel(" "); 38 JLabel L18=new JLabel(""); 39 JLabel L19=new JLabel(" "); 40 JTextField[]T={ 41 new JTextField(12),new JTextField(12),new JTextField(12),new JTextField(12),new JTextField(12),new JTextField(8),new JTextField(8),new JTextField(8),new JTextField(8),new JTextField(8),new JTextField(5) 42 }; 43 JButton B1=new JButton("开始答题"); 44 JButton B2=new JButton("提交"); 45 46 JFrame f=new JFrame(); 47 48 String username=new String(); 49 int i; 50 int k; 51 int n; 52 long begintime; 53 long endtime; 54 long time; 55 int[]a=new int[5]; 56 int[]b=new int[5]; 57 int[]c=new int[5]; 58 int[]d=new int[5]; 59 int[]answer=new int[5]; 60 61 62 public MyFrame() 63 { 64 getContentPane().setBackground(Color.WHITE); 65 this.setVisible(true); 66 this.setTitle("四则运算答题"); 67 Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); 68 setBounds((d.width - 502) / 2, (d.height - 450) / 2, 502, 450); 69 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 70 this.setResizable(false); 71 getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 12, 10)); 72 setJMenuBar(M1); 73 M1.add(M2); 74 M2.add(M3); 75 M2.add(M4); 76 M2.add(M5); 77 M2.add(M6); 78 M2.add(M7); 79 L12.setForeground(Color.RED); 80 L12.setFont(new Font("宋体", Font.BOLD, 25)); 81 getContentPane().add(L12); 82 L13.setForeground(SystemColor.textHighlight); 83 L13.setFont(new Font("宋体", Font.BOLD, 25)); 84 getContentPane().add(L13); 85 L1.setFont(new Font("宋体", Font.PLAIN, 20)); 86 getContentPane().add(L1);