软件工程-作业
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int integer = Integer.parseInt(Text.getText()); long startTime=System.currentTimeMillis(); Factorial factorial = new Factorial(); String computeresult = factorial.process(integer).toString(); information.setText(factorial.time(startTime)+'\n'+factorial.countbig(computeresult)); result.setText(computeresult); }
1 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 2 // TODO add your handling code here: 3 String input = Text.getText(); 4 if (input.equals("")) { 5 JOptionPane.showMessageDialog(null, "请输入要计算阶乘的数字"); 6 } 7 else{ 8 for(int i=0;i<input.length();i++) { 9 if(input.charAt(i)<='9'&&input.charAt(i)>='0'); 10 else { 11 JOptionPane.showMessageDialog(null, "请不要输入乱七八糟的玩意"); 12 return; 13 } 14 } 15 int integer = Integer.parseInt(input); 16 17 long startTime = System.currentTimeMillis(); 18 Factorial factorial = new Factorial(); 19 String computeresult = factorial.process(integer).toString(); 20 information.setText(factorial.time(startTime) + '\n' + factorial.countbig(computeresult)); 21 result.setText(computeresult); 22 } 23 24 }