package com.bjpowernode;
class User {
private String name;
private String password;
private static int number;
public User() {
number++;
}
public User(String name) {
this.setName(name);
number++;
}
public User(String password, String name) {
this.setPassword(password);
this.setName(name);
number++;
}
public void tell() {
System.out.println("用户名:" + getName() + ",口令:" + getPassword()+",用户的个数:" + number);
}
public void setName(String n) {
name = n;
}
public void setPassword(String P) {
password = P;
}
public String getName() {
return name;
}
public String getPassword() {
return password;
}
}
public class MyTest {
public static void main(String args[]) {
User user1 = new User("老朱", "123");
user1.tell();
User user2 = new User("新阳", "456");
user2.tell();
User user3 = new User("猪心央", "789");
user3.tell();
}
}
用户名:123,口令:老朱,用户的个数:1
用户名:456,口令:新阳,用户的个数:2
用户名:789,口令:猪心央,用户的个数:3
Process finished with exit code 0