github项目地址 :https://github.com/feser-xuan/Arithmetic_test3_UI
实验要求
-
在《实验二 软件工程个人项目》中,同学们实现了一个命令行四则运算出题小程序,本次实验采用结对编程方式,设计开发一个小学生四则运算练习软件,使之具有以下功能:
-
(1)由计算机从题库文件中随机选择20道加减乘除混合算式,用户输入算式答案,程序检查答案是否正确,每道题正确计5分,错误不计分,20道题测试结束后给出测试总分;
-
(2)题库文件可采用实验二的方式自动生成,也可以手工编辑生成,文本格式如下:
-
(3)程序为用户提供三种进阶四则运算练习功能选择:百以内整数算式(必做)、带括号算式、真分数算式练习;
- (4)程序允许用户进行多轮测试,提供用户多轮测试分数柱状图,示例如下:
-
(5)程序记录用户答题结果,当程序退出再启动的时候,可为用户显示最后一次测试的结果,并询问用户可否进行新一轮的测试;
-
(6)测试有计时功能,测试时动态显示用户开始答题后的消耗时间。
-
(7)程序人机交互界面是GUI界面(WEB页面、APP页面都可),界面支持中文简体(必做)/中文繁体/英语,用户可以进行语种选择。
1、需求分析
4、运行测试
- 设计交互界面,首页登陆
- 答题界面
- 答题完毕后,可以点击保存练习过的题目(包括自己答题的答案)
- 答题结束后,可以查看自己得分情况(具体的用一个柱状统计图展示)
5、核心代码
- 登录界面
1 public class Login { 2 3 public Login() 4 { 5 JFrame f=new JFrame(); 6 f.setTitle("小学生四则运算答题系统"); 7 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 8 f.setExtendedState(JFrame.MAXIMIZED_BOTH); 9 f.setVisible(true); 10 11 //设置窗口的大小和位置 12 f.setSize(500,500); 13 f.setLocation(200,200); 14 15 Container con=f.getContentPane();//生成一个容器 16 con.setLayout(new GridLayout(7,1)); 17 18 JPanel pan1 =new JPanel(); 19 JLabel title=new JLabel("欢迎登陆小学生四则运算答题系统"); 20 title.setFont(new Font("宋体",Font.BOLD, 20)); 21 pan1.add(title); 22 con.add(pan1); 23 //生成一个新的版 24 JPanel pan2 = new JPanel(); 25 JPanel pan3 = new JPanel(); 26 JPanel pan4 = new JPanel(); 27 JPanel pan5 = new JPanel(); 28 29 con.add(pan2); 30 con.add(pan3); 31 con.add(pan4); 32 con.add(pan5); 33 34 JLabel name=new JLabel("用户名"); 35 pan2.add(name); 36 TextField tf_name=new TextField(20); 37 pan2.add(tf_name); 38 39 JLabel pass = new JLabel("密码"); 40 pan3.add(pass); 41 TextField password=new TextField(20); 42 password.setEchoChar(‘*‘); 43 pan3.add(password); 44 45 JButton b_log=new JButton("登陆"); 46 b_log.addActionListener(new ActionListener() { 47 public void actionPerformed(ActionEvent e) { 48 // TODO Auto-generated method stub 49 //获取用户名和密码,进行校验 50 String myUsername=tf_name.getText(); 51 String myPassword=password.getText(); 52 if(myUsername.equals("admin")&& myPassword.equals("123456")){ 53 JOptionPane.showMessageDialog(null, "登陆成功!"); 54 f.dispose(); 55 MyExGUI ui = new MyExGUI(); 56 57 } 58 else{ 59 JOptionPane.showMessageDialog(null, "账号或密码错误!"); 60 name.setText( ""); 61 password.setText( ""); 62 } 63 64 } 65 }); 66 pan4.add(b_log); 67 68 JButton b_exit=new JButton("退出"); 69 b_exit.addActionListener(new ActionListener() { 70 public void actionPerformed(ActionEvent e) { 71 // TODO Auto-generated method stub 72 JOptionPane.showMessageDialog(null, "谢谢使用!"); 73 f.setVisible(false);//隐藏窗体 74 System.exit(0);//退出程序 75 } 76 }); 77 pan5.add(b_exit); 78 //登陆和退出这两个按钮放在第四个版面上 79 80 81 } 82 83 }
- 练习界面
1 package ui_test; 2 3 import java.awt.*; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.io.BufferedOutputStream; 7 import java.io.File; 8 import java.io.FileOutputStream; 9 import java.io.IOException; 10 import java.util.ArrayList; 11 12 import javax.swing.*; 13 14 15 public class MyExGUI extends JFrame{ 16 ArrayList<String> user_zongti = new ArrayList<String>(); 17 ArrayList<String> user_zonganswer = new ArrayList<String>(); 18 ArrayList<String> user_answer = new ArrayList<String>(); 19 ArrayList<String> true_answer = new ArrayList<String>(); 20 ArrayList<String> jta_timu = new ArrayList<String>(); 21 ArrayList<String> jta_zong = new ArrayList<String>(); 22 ArrayList<Integer> user_fenshu = new ArrayList<Integer>(); 23 JMenuBar jmb; //菜单条组件 24 JMenu menu1, menu2, menu3, menu4, menu5;//菜单 25 JMenuItem item1, item2, item3, item4, item5, item6;//菜单项 26 JMenu build; //二级菜单 27 JMenuItem file, project; 28 TextArea answer_all = new TextArea(); 29 TextField jta = new TextField(); 30 TextField jta_answer = new TextField(); 31 JLabel num_answer = new JLabel(); 32 JLabel answer1; 33 JToolBar jtb;//工具条 34 JButton jb1, jb2, jb3, jb4, jb5, jb6, jb7,jb_next; 35 int answer_count; 36 int answer_fenshu; 37 public MyExGUI() 38 { 39 //创建菜单 40 jmb = new JMenuBar(); 41 42 menu1 = new JMenu("文件(F)"); 43 menu1.setMnemonic(‘f‘); //助记符 44 menu2 = new JMenu("编辑"); 45 menu2.setMnemonic(‘E‘); 46 menu3 = new JMenu("格式"); 47 menu4 = new JMenu("查看"); 48 menu5 = new JMenu("帮助"); 49 50 build = new JMenu("新建"); 51 52 file = new JMenuItem("文件"); 53 project = new JMenuItem("答题"); 54 item1 = new JMenuItem("打开"); 55 item2 = new JMenuItem("保存(S)"); 56 item3 = new JMenuItem("另存为"); 57 item4 = new JMenuItem("页面设置"); 58 item5 = new JMenuItem("打印"); 59 item6 = new JMenuItem("退出"); 60 61 answer1 = new JLabel("第 1 题"); 62 63 64 65 //添加菜单项至菜单上 66 build.add(file); 67 build.add(project); 68 69 menu1.add(build); 70 menu1.add(item1); 71 menu1.add(item2); 72 menu1.add(item3); 73 menu1.addSeparator(); 74 menu1.add(item4); 75 menu1.add(item5); 76 menu1.add(item6); 77 //将菜单加入至菜单栏 78 jmb.add(menu1); 79 jmb.add(menu2); 80 jmb.add(menu3); 81 jmb.add(menu4); 82 jmb.add(menu5); 83 84 85 JPanel contentPanel = new JPanel(); 86 contentPanel.setLayout(null); 87 JLabel daan = new JLabel("答案"); 88 JLabel dengyu = new JLabel("="); 89 num_answer=answer1; 90 num_answer.setFont(new Font("宋体",Font.BOLD, 22)); 91 jb_next = new JButton("下一题"); 92 jta.setFont(new Font("宋体",Font.BOLD, 22)); 93 jta_answer.setFont(new Font("宋体",Font.BOLD, 22)); 94 jb_next.setFont(new Font("宋体",Font.BOLD, 22)); 95 daan.setFont(new Font("宋体",Font.BOLD, 22)); 96 dengyu.setFont(new Font("宋体",Font.BOLD, 22)); 97 98 contentPanel.add(num_answer); 99 contentPanel.add(daan); 100 contentPanel.add(dengyu); 101 contentPanel.add(jta); 102 103 contentPanel.add(jta_answer); 104 contentPanel.add(answer_all); 105 contentPanel.add(jb_next); 106 107 num_answer.setBounds(90, 20, 130, 50); 108 daan.setBounds(250, 20, 90, 50); 109 jta.setBounds(50, 70, 150, 30); 110 dengyu.setBounds(205, 70, 20, 20); 111 jta_answer.setBounds(230, 70, 100, 30); 112 jb_next.setBounds(350, 70, 110, 30); 113 answer_all.setBounds(50, 120, 400, 300); 114 115 this.setJMenuBar(jmb); //添加菜单栏,不能设定位置,会自动放在最上部 116 this.add(contentPanel); 117 118 this.setTitle("在线答题系统"); 119 this.setSize(600, 500); 120 this.setVisible(true); 121 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 122 item1.addActionListener(new ActionListener() { 123 124 @Override 125 public void actionPerformed(ActionEvent arg0) { 126 // TODO Auto-generated method stub 127 JFileChooser jfc=new JFileChooser(); 128 jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES ); 129 jfc.showDialog(new JLabel(), "选择"); 130 File file=jfc.getSelectedFile(); 131 if(file.isDirectory()){ 132 // System.out.println("文件夹:"+file.getAbsolutePath()); 133 }else if(file.isFile()){ 134 String s=file.getAbsolutePath(); 135 } 136 } 137 }); 138 item2.addActionListener(new ActionListener() { 139 140 @Override 141 public void actionPerformed(ActionEvent arg0) { 142 FileOutputStream outSTr = null; 143 BufferedOutputStream Buff = null; 144 boolean flag = true; 145 File file; 146 //String test ; 147 do{ 148 //test = "test"+count; 149 150 String inputValue = JOptionPane.showInputDialog("Please input file name"); 151 file = new File(inputValue+".txt"); 152 if (!file.exists()) { 153 // 创建文件 154 try { 155 156 flag=file.createNewFile(); 157 158 } catch (IOException e) { 159 e.printStackTrace(); 160 161 } 162 flag=false; 163 } 164 else{ 165 166 JOptionPane.showMessageDialog(null, "该文件名已存在,请重新输入", "ERROR", JOptionPane.ERROR_MESSAGE); 167 flag=true; 168 } 169 }while(flag); 170 //写入文件 171 String u_answer; 172 try { 173 outSTr = new FileOutputStream(file); 174 Buff = new BufferedOutputStream(outSTr); 175 System.out.println("选择是后执行的代码"+user_zongti.size()+user_answer.size()); 176 for (int i = 0; i < user_zongti.size(); i++) 177 { 178 try { 179 Buff.write(user_zongti.get(i).getBytes()); 180 Buff.write(" ".getBytes()); 181 u_answer = user_answer.get(i); 182 if(u_answer.equals("")) 183 u_answer ="没有作答"; 184 185 Buff.write(u_answer.getBytes()); 186 Buff.write("\r\n".getBytes()); 187 } catch (IOException e) { 188 e.printStackTrace(); 189 i--; 190 } 191 } 192 Buff.flush(); 193 Buff.close(); 194 195 } catch (IOException e) { 196 e.printStackTrace(); 197 } 198 //Buff.close(); 199 try { 200 outSTr.close(); 201 } catch (IOException e) { 202 e.printStackTrace(); 203 } 204 user_zongti.clear(); 205 user_answer.clear(); 206 } 207 }); 208 209 210 project.addActionListener(new ActionListener() { 211 212 @Override 213 public void actionPerformed(ActionEvent arg0) { 214 arithmetic art = new arithmetic(); 215 true_answer=art.list_answer; 216 jta_timu = art.list_timu; 217 jta_zong = art.list; 218 answer_count=1; 219 answer_all.setText(""); 220 for (int i = 0; i < art.list_timu.size(); i++) 221 { 222 user_zongti.add(jta_zong.get(i)); 223 answer_all.append(jta_timu.get(i)); 224 answer_all.append("\r\n"); 225 } 226 num_answer.setText("第 "+answer_count+" 题"); 227 jta.setText(jta_timu.get(answer_count-1)); 228 answer_count++; 229 230 231 } 232 }); 233 jb_next.addActionListener(new ActionListener() { 234 235 @Override 236 public void actionPerformed(ActionEvent arg0) { 237 String temp; 238 temp = jta_answer.getText(); 239 240 if(jta.getText().equals("")) 241 { 242 JOptionPane.showMessageDialog(null, "错误,请导入题库", "错误", JOptionPane.ERROR_MESSAGE); 243 return; 244 } 245 jta_answer.setText(""); 246 if(answer_count<=20) 247 { 248 if(isInteger(temp)) 249 { 250 251 user_answer.add(temp); 252 System.out.println("选择否后执行的代码"+temp+"user_size"+user_answer.size()); 253 num_answer.setText("第 "+answer_count+" 题"); 254 jta.setText(jta_timu.get(answer_count-1)); 255 answer_count++; 256 } 257 else{ 258 JOptionPane.showMessageDialog(null, "错误", "请输入数字", JOptionPane.ERROR_MESSAGE); 259 } 260 } 261 else{ 262 user_answer.add(temp); 263 System.out.println("选择否后执行的代码"+temp+"user_size"+user_answer.size()); 264 answer_fenshu=0; 265 for(int i=0;i<user_answer.size();i++) 266 { 267 if(user_answer.get(i).equals(true_answer.get(i))) 268 answer_fenshu+=5; 269 } 270 user_fenshu.add(answer_fenshu); 271 Object[] options = { "是", "取消" }; 272 int res=JOptionPane.showOptionDialog(null, "点击以继续 查看成绩", "答题完毕", 273 JOptionPane.DEFAULT_OPTION, JOptionPane.YES_NO_OPTION, 274 null, options, options[0]); 275 if(res==JOptionPane.YES_OPTION){ 276 chart ct =new chart(user_fenshu); 277 ct.setVisible(true); 278 279 }else{ 280 Object[] option = { "是", "取消" }; 281 int res1=JOptionPane.showOptionDialog(null, "继续新一轮答题", "新一轮答题", 282 JOptionPane.DEFAULT_OPTION, JOptionPane.YES_NO_OPTION, 283 null, option, option[0]); 284 285 if(res1==JOptionPane.YES_OPTION){ 286 arithmetic art = new arithmetic(); 287 true_answer=art.list_answer; 288 289 jta_timu = art.list; 290 answer_count=1; 291 answer_all.setText(""); 292 jta_answer.setText(""); 293 for (int i = 0; i < art.list_timu.size(); i++) 294 { 295 user_zongti.add(jta_timu.get(i)); 296 answer_all.append(jta_timu.get(i)); 297 answer_all.append("\r\n"); 298 } 299 num_answer.setText("第 "+answer_count+" 题"); 300 jta.setText(jta_timu.get(answer_count-1)); 301 answer_count++; 302 303 }else{ 304 305 } 306 307 } 308 309 310 311 } 312 313 314 315 } 316 }); 317 318 319 320 321 } 322 323 public static boolean isInteger(String str) { 324 for (int i = str.length();--i>=0;){ 325 if (!Character.isDigit(str.charAt(i))){ 326 return false; 327 } 328 } 329 return true; 330 } 331 332 333 334 335 }
- 绘图界面
1 package ui_test; 2 3 import java.awt.Color; 4 import java.awt.Graphics; 5 import java.awt.Graphics2D; 6 import java.util.ArrayList; 7 import java.util.Random; 8 9 import javax.swing.JFrame; 10 11 public class chart extends JFrame{ 12 //绘制柱形统计图 13 ArrayList<Integer> ran=new ArrayList<Integer>(); 14 public chart(ArrayList<Integer> scores) 15 { 16 super(); 17 getContentPane().setForeground(Color.CYAN); 18 setForeground(Color.CYAN); 19 setBackground(Color.CYAN); 20 for(int i=0;i<scores.size();i++) 21 { 22 ran.add(scores.get(i)); 23 System.out.println(scores.get(i)); 24 } 25 26 setTitle("绘制柱形图"); 27 setSize(600, 400); 28 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 29 } 30 @Override 31 public void paint(Graphics g){ 32 int Width = getWidth(); 33 int Height = getHeight(); 34 int leftMargin = 20;//柱形图左边界 35 int topMargin = 50;//柱形图上边界 36 Graphics2D g2 = (Graphics2D) g; 37 g2.setColor(Color.WHITE);//绘制白色背景 38 g2.fillRect(0, 0, Width, Height-100);//绘制矩形图 39 g2.setColor(Color.black); 40 for(int i=0;i<=10;i++) 41 { 42 //绘制灰色横线和百分比 43 g2.drawString((100-10*i)+"", 15, topMargin+30*i); 44 g2.drawLine(5, topMargin+30*i, Width, topMargin+30*i);//绘制灰色横线 45 } 46 g2.setColor(Color.YELLOW); 47 for(int i=0;i<=ran.size();i++) 48 { 49 //绘制柱形图 50 int step = (i+1)*40;//设置每个柱形图的水平间隔为40 51 //绘制矩形 52 g2.fillRoundRect(leftMargin+step*2-5,(100-ran.get(i))*3+50, 40, 300-(100-ran.get(i))*3, 40, 10); 53 //列出测试轮数 54 g2.drawString("第"+(i+1)+"轮", leftMargin+step*2, 380); 55 } 56 } 57 58 59 }
- 随机产生四则远算式
1 package ui_test; 2 3 import java.io.BufferedOutputStream; 4 import java.io.File; 5 import java.io.FileOutputStream; 6 import java.io.IOException; 7 import java.util.ArrayList; 8 import java.util.Random; 9 import java.util.Scanner; 10 11 public class arithmetic 12 { 13 ArrayList<String> list = new ArrayList<String>(); 14 ArrayList<String> list_timu = new ArrayList<String>(); 15 ArrayList<String> list_answer = new ArrayList<String>(); 16 public arithmetic() 17 { 18 FileOutputStream outSTr = null; 19 BufferedOutputStream Buff = null; 20 int number_n=20,count; 21 22 ArrayList<String> list_temp = new ArrayList<String>(); 23 String[] operator = new String[]{"+","-","*","/"}; 24 25 Random rand = new Random(); 26 File file1 = new File("result.txt"); 27 if (file1.exists()) { 28 // 创建文件 29 try { 30 file1.createNewFile(); 31 } catch (IOException e) { 32 e.printStackTrace(); 33 } 34 } 35 36 37 while(number_n>0) 38 { 39 int[] number_temp = new int[rand.nextInt(2)+3]; 40 String[] str_temp = new String[number_temp.length-1]; 41 for(int i=0;i<number_temp.length;i++) 42 { 43 if(i<number_temp.length-1) 44 { 45 number_temp[i]=rand.nextInt(100); 46 list_temp.add(String.valueOf(number_temp[i])); 47 str_temp[i]=operator[rand.nextInt(4)]; 48 list_temp.add(str_temp[i]); 49 50 } 51 52 else 53 { 54 number_temp[i]=rand.nextInt(100); 55 list_temp.add(String.valueOf(number_temp[i])); 56 } 57 } 58 59 count=calculate_RPN(produce_RPN(list_temp)); 60 if(count !=-1) 61 { 62 list_timu.add(transform_string(list_temp)); 63 list_answer.add(String.valueOf(count)); 64 list_temp.add(" = "+count); 65 list.add(transform_string(list_temp)); 66 number_n--; 67 list_temp.clear(); 68 } 69 else 70 list_temp.clear(); 71 System.out.println(number_n); 72 73 } 74 try { 75 outSTr = new FileOutputStream(file1); 76 Buff = new BufferedOutputStream(outSTr); 77 try { 78 Buff.write("201571030104 丁炜轩".getBytes()); 79 Buff.write("\r\n".getBytes()); 80 } catch (IOException e) { 81 e.printStackTrace(); 82 } 83 for (int i = 0; i < list.size(); i++) 84 { 85 try { 86 Buff.write(list.get(i).getBytes()); 87 Buff.write("\r\n".getBytes()); 88 } catch (IOException e) { 89 e.printStackTrace(); 90 i--; 91 } 92 } 93 Buff.flush(); 94 Buff.close(); 95 96 } catch (IOException e) { 97 e.printStackTrace(); 98 } 99 //Buff.close(); 100 try { 101 outSTr.close(); 102 } catch (IOException e) { 103 e.printStackTrace(); 104 } 105 106 for (int i = 0; i < list.size(); i++) 107 { 108 System.out.print(list.get(i)); 109 System.out.println(); 110 } 111 System.out.print("计算完毕!"); 112 113 } 114 115 public static int calculate_RPN(ArrayList<String> list_temp) 116 { 117 int i=0,t; 118 double a=0,b=0; 119 String l_temp; 120 Stack sk=new Stack(20); 121 for(t=0;t<list_temp.size();t++) 122 { 123 l_temp = list_temp.get(i++); 124 if(!isInteger(l_temp)) 125 { 126 b = sk.mypop(); 127 a = sk.mypop(); 128 switch(l_temp) 129 { 130 case "+":sk.mypush(a+b);break; 131 case "-":sk.mypush(a-b);break; 132 case "*":sk.mypush(a*b);break; 133 case "/": 134 if(b==0) 135 return -1; 136 sk.mypush(a/b);break; 137 } 138 System.out.println("st.mytop: "+sk.mypeek()); 139 } 140 else{ 141 sk.mypush((double)Integer.parseInt(l_temp)); 142 } 143 144 } 145 if(!sk.myisempty()) 146 { 147 a = sk.mypop(); 148 b = a-(int)a; 149 System.out.println("a: "+a); 150 if(a>0 && b==0 ) 151 { 152 return (int)a; 153 } 154 else 155 return -1; 156 } 157 else 158 return -1; 159 160 } 161 162 163 public static ArrayList<String> produce_RPN(ArrayList<String> list_temp) 164 { 165 int t=0,i=0; 166 String tmp; 167 Tack mytack = new Tack(20); 168 ArrayList<String> lt_temp = new ArrayList<String>(); 169 while(true) 170 { 171 tmp = list_temp.get(i++); 172 if(isInteger(tmp)) 173 { 174 lt_temp.add(tmp); 175 } 176 else{ 177 if(mytack.myisempty()) 178 { 179 mytack.mypush(tmp); 180 } 181 182 183 else{ 184 if(isCPriority(tmp, mytack.mypeek())) 185 mytack.mypush(tmp); 186 else{ 187 lt_temp.add(mytack.mypop()); 188 mytack.mypush(tmp); 189 } 190 191 } 192 } 193 if(i>=list_temp.size()) 194 { 195 while(!mytack.myisempty()) 196 lt_temp.add(mytack.mypop()); 197 System.out.println(transform_string(list_temp)); 198 list_temp = lt_temp; 199 System.out.println(list_temp); 200 return list_temp; 201 } 202 } 203 204 205 } 206 207 208 209 public static boolean isInteger(String str) { 210 for (int i = str.length();--i>=0;){ 211 if (!Character.isDigit(str.charAt(i))){ 212 return false; 213 } 214 } 215 return true; 216 } 217 public static boolean isCPriority(String str,String s) { 218 if((str+s).equals("*+") || (str+s).equals("*-") || (str+s).equals("/+") || (str+s).equals("/-")) 219 return true; 220 else 221 return false; 222 } 223 public static String transform_string(ArrayList<String> list_temp) 224 { 225 String s=""; 226 for(int i=0;i<list_temp.size();i++) 227 { 228 s+=list_temp.get(i); 229 } 230 return s; 231 232 } 233 234 static class Stack 235 { 236 int mytop; 237 double stk[]; 238 239 public Stack(int num) { 240 mytop=-1; 241 stk=new double[num]; 242 } 243 /*出栈*/ 244 double mypop() 245 { 246 double peek=stk[mytop]; 247 mytop--; 248 return peek; 249 } 250 /*入栈*/ 251 void mypush(double x) 252 { 253 mytop++; 254 stk[mytop]=x; 255 256 } 257 /*判空*/ 258 Boolean myisempty() 259 { 260 if(mytop==-1) 261 return true; 262 else 263 return false; 264 } 265 /*取栈顶元素*/ 266 double mypeek() 267 { 268 double peek=stk[mytop]; 269 return peek; 270 } 271 /*栈大小*/ 272 int mysize() 273 { 274 return mytop+1; 275 } 276 } 277 278 static class Tack 279 { 280 int mytop; 281 String tk[]; 282 283 public Tack(int num) { 284 mytop=-1; 285 tk=new String[num]; 286 } 287 /*出栈*/ 288 String mypop() 289 { 290 String peek=tk[mytop]; 291 mytop--; 292 return peek; 293 } 294 /*入栈*/ 295 void mypush(String x) 296 { 297 mytop++; 298 tk[mytop]=x; 299 300 } 301 /*判空*/ 302 Boolean myisempty() 303 { 304 if(mytop==-1) 305 return true; 306 else 307 return false; 308 } 309 /*取栈顶元素*/ 310 String mypeek() 311 { 312 String peek=tk[mytop]; 313 return peek; 314 } 315 /*栈大小*/ 316 int mysize() 317 { 318 return mytop+1; 319 } 320 321 322 } 323 324 325 }
- main函数
1 package ui_test; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 Login lg = new Login(); 7 //new MyExGUI(); 8 9 } 10 11 }
6、总结
通过本次实验,对于结对编程有了非常浓厚的兴趣,也体会到了结对编程对于项目的重要意义,总之收获很多。
在项目的设计、编写、调试、优化中,遇到了很多熟悉而又陌生的问题,花费的时间也比较多。由于对于计算机语言的偏好,对于有些语言,我选择舍弃,注重计算机的一门语言,努力做到最好。闻道有先后,术业有专攻。
7、结对编程(照片)
8、展示PSP
PSP2.1 |
任务内容 |
计划完成需要的时间(min) |
实际完成需要的时间(min) |
Planning |
计划 |
30 |
30 |
Estimate |
估计这个任务需要多少时间,并规划大致工作步骤 |
30 |
30 |
Development |
开发 |
360 |
300 |
Analysis |
需求分析 (包括学习新技术) |
100 |
60 |
Design Spec |
生成设计文档 |
10 |
10 |
Design Review |
设计复审 (和同事审核设计文档) |
20 |
10 |
Coding Standard |
代码规范 (为目前的开发制定合适的规范) |
10 |
5 |
Design |
具体设计 |
60 |
35 |
Coding |
具体编码 |
120 |
130 |
Code Review |
代码复审 |
10 |
10 |
est |
测试(自我测试,修改代码,提交修改) |
30 |
40 |
Reporting |
报告 |
30 |
43 |
Test Report |
测试报告 |
25 |
30 |
Size Measurement |
计算工作量 |
2 |
3 |
Postmortem & Process Improvement Plan |
事后总结 ,并提出过程改进计划 |
3 |
10 |