0708---oop学习--用户密码管理
生活随笔
收集整理的這篇文章主要介紹了
0708---oop学习--用户密码管理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
需求說明:
模擬實現用戶密碼管理:輸入舊的用戶名和密碼,如果正確,方有權限更新;從鍵盤獲取新的密碼,進行更新
用戶登錄以及更新類:
public class Password {Scanner input = new Scanner(System.in);String userName = "admin1";String passWord = "111111";public void Login() {System.out.println("請輸入登錄賬號以及密碼!");System.out.print("請輸入登錄名:");String user = input.next();System.out.print("請輸入密碼:");String password = input.next();if(user.equals(userName)&&password.equals(passWord)) {System.out.println();this.NewPassword();}else {System.out.println("用戶名和密碼不匹配!您沒有權限更換管理員信息。");}}private void NewPassword() {System.out.print("請輸入新密碼:");passWord = input.next();System.out.println("修改密碼成功,您的新密碼為:"+passWord);}}測試類:
public class Text1 {public static void main(String[] args) {Password pw = new Password();pw.Login();}}運行結果:
??
?
轉載于:https://www.cnblogs.com/Dean-0/p/11152271.html
總結
以上是生活随笔為你收集整理的0708---oop学习--用户密码管理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [算法模版]Link-Cut-Tree
- 下一篇: 7.8