From f50d42313c3ddfe824a44ffdabd3853e35d0a7c6 Mon Sep 17 00:00:00 2001 From: nxist2202005024 <1240456549@qq.com> Date: Thu, 20 Jun 2024 20:57:32 +0800 Subject: [PATCH] ADD file via upload --- Account.java | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Account.java diff --git a/Account.java b/Account.java new file mode 100644 index 0000000..6b91854 --- /dev/null +++ b/Account.java @@ -0,0 +1,55 @@ +package com.javaBean; + +/** + * Account类简化版,仅包含用户的登录信息。 + */ +public class Account { + String userid; // 用户ID + String password; // 登录密码 + + /** + * 默认构造函数,创建一个空白账户对象。 + */ + public Account() { + // 默认构造函数无需特别处理,保持空白即可 + } + + /** + * 构造函数,用于初始化Account对象的userid和password属性。 + * + * @param userid 用户ID + * @param password 登录密码 + */ + public Account(String userid, String password) { + this.userid = userid; + this.password = password; + } + + // Getter and Setter 方法,仅保留userid和password的访问器 + public String getuserid() { + return userid; + } + + public void setuserid(String userid) { + this.userid = userid; + } + + public String getpassword() { + return password; + } + + public void setpassword(String password) { + this.password = password; + } + + /** + * 重写toString方法,提供友好的字符串表示形式,通常用于日志输出或简单显示。 + * + * @return 字符串格式:用户ID:密码(实际应用中,直接打印密码可能不安全,此处仅为示例) + */ + @Override + public String toString() { + // 注意:在真实环境中,直接在toString方法中暴露密码是不安全的,这里为了演示才这样写 + return this.userid + ":" + "********"; // 用星号代替密码的实际显示,以增强安全性提示 + } +} \ No newline at end of file