Java课程设计-随机密码生成器

1.团队课程设计博客链接

团队课程设计博客地址

2.个人负责模板

设计程序运行界面,数据的输入,判断数据输入类型的错误,判断密码类型是否选择。

3.自己的代码提交记录截图

4自己负责模块或任务详细说明

(一)总体设计
1.系统主要功能
(1)输入生成密码长度;
(2)判断输入是否正确,包括输入的是否是数字以及输入的长度是否超出有效长度;
(3)判断是否选择生成密码类型;
(4)生成随机密码。
流程图:

(二)本人负责的主要功能展示与代码分析
运行程序:

主要代码:
private void GeneratePasswordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GeneratePasswordButtonActionPerformed
Password getpassword = new Password();
String passwordlength = InputField.getText();//获取密码长度
int b = 0;
try {
b = Integer.parseInt(passwordlength);
jLabel5.setText(null);
} catch (NumberFormatException e) {
jLabel5.setText("输入错误,请重新输入!");
}
if (b > 0 && b <= 20) {
r = getpassword.passwordType(X, Y, Z, b);
if(r.equals(" ")){
jLabel5.setText("请选择密码类型");
}
}else{
jLabel5.setText("输入错误,请重新输入");
}
OutputField.setText(r);
}//GEN-LAST:event_GeneratePasswordButtonActionPerformed

private void ChooseNumberButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChooseNumberButtonActionPerformed
    if (x > 0) {
        X = 1;
        x = 0;
    } else {
        x = 1;
        X = 0;
    }
}//GEN-LAST:event_ChooseNumberButtonActionPerformed

private void ChooseLowerCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChooseLowerCaseButtonActionPerformed
    if (y > 0) {
        Y = 1;
        y = 0;
    } else {
        y = 1;
        Y = 0;
    }
}//GEN-LAST:event_ChooseLowerCaseButtonActionPerformed

private void ChooseUpperCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChooseUpperCaseButtonActionPerformed
    if (z > 0) {
        Z = 1;
        z = 0;
    } else {
        z = 1;
        Z = 0;
    }
}//GEN-LAST:event_ChooseUpperCaseButtonActionPerformed

private void InputFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_InputFieldActionPerformed

}//GEN-LAST:event_InputFieldActionPerformed

private void OutputFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OutputFieldActionPerformed

}//GEN-LAST:event_OutputFieldActionPerformed

private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized

}//GEN-LAST:event_formComponentResized

public static void main(String args[]) {

    java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            new PasswordFrame().setVisible(true);
        }
    });
}
private static int X;//选择数字的密码
private static int Y;//选择小写字母的密码
private static int Z;//选择大写字母的密码
private static int x = 1;//选择或关闭数字密码
private static int y = 1;//选择或关闭小写字母密码
private static int z = 1;//选择或关闭大写字母密码
private static String r = "";
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton ChooseLowerCaseButton;
private javax.swing.JRadioButton ChooseNumberButton;
private javax.swing.JRadioButton ChooseUpperCaseButton;
private javax.swing.JButton GeneratePasswordButton;
private javax.swing.JLabel HeadLine;
private javax.swing.JTextField InputField;
private javax.swing.JTextField OutputField;
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
// End of variables declaration//GEN-END:variables

}

5.课程设计感想

总的来说,这次课程设计对我来说很难,经过两天换了两次题目,结果发现都做不出来,前后浪费了两天时间,最后不得已选了个最简单的D类题目。。。。

posted @ 2017-06-22 15:28  一辆坦克他爹  阅读(2046)  评论(0编辑  收藏  举报