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類題目。。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM