java作业 4

public class dog {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Dog per=new Dog("xxx","黑白","1岁","二哈");
  per.tell();

 }

}
class Dog{
 private String N;
 private String C;
 private String A;
 private String Nature;
 public Dog(String N,String C,String A,String Nature){
  this.setName(N);
  this.setColour(C);
  this.setAge(A);
  this.setNature(Nature);
 
 }
 public String getName() {
  return N;
 }
 public void setName(String name) {
  N = name;
 }
 public String getColour() {
  return C;
 }
 public void setColour(String colour) {
  C = colour;
 }
 public String getAge() {
  return A;
 }
 public void setAge(String age) {
  A = age;
 }
 public String getNature() {
  return Nature;
 }
 public void setNature(String nature) {
  Nature = nature;
 }
 public void tell(){
  System.out.println("名字:"+getName()+",颜色:"+getColour()+",年龄:"+getAge()+",属性:"+getNature());
 }
}

 

 

public class java {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  User per1=new User("xxx","233");
  per1.print();
  User per2=new User("xx","2333");
  per2.print();
  new User().count();
 }

}
class User{
 private String Name;
 private String Password;
 private static int count;
 public User(){
   count++;
 }
 public User(String Name,String Password){
  this.Name=Name;
  this.Password=Password;
   count++;
 }
 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;
 }
 public static int getCount() {
  return count;
 }
 public static void setCount(int count) {
  User.count = count;
 }
 public void print(){
  System.out.println("用户名:"+Name+"\t"+"口令密码:"+Password);
 }
 public void count(){
  System.out.println("用户个数:"+(count-1));
 }
}

你可能感兴趣的:(java作业 4)