JAVA简单加急。编写管理员类。如图
2个回答
展开全部
public class Admin {
private String name;
private String password;
public Admin(String name, String password) {
this.name = name;
this.password = password;
}
public void show() {
System.out.println("姓名:" + name + ",密码:" + password);
}
public static void main(String[] args) {
Admin admin1 = new Admin("admin1", "111111");
admin1.show();
Admin admin2 = new Admin("admin2", "222222");
admin2.show();
}
}
2015-12-21
展开全部
public class Admin {
private String name;
private String password;
public Admin(String name, String password) {
this.name = name;
this.password = password;
}
public Admin() {
//无参构造
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "Admin [name=" + name + ", password=" + password + "]";//重写tostring方法,输出格式可随用户需要改动
}
public void show(){
System.out.println(this);//打印自身
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询