Fourth time Java Job

Source: Internet
Author: User

public class Tvbdog {

public static void Main (string[] args) {
Dog Per=new Dog ("Chen", "Yellow", "18 months", "Tibetan Mastiff");
Per.tell ();

}

}
Class dog{
Private String Name;
Private String colour;
Private String age;
Private String Nature;
Public Dog (String name,string colour,string age,string Nature) {
This.setname (Name);
This.setcolour (colour);
This.setage (age);
This.setnature (Nature);
}
public void Tell () {
System.out.println ("Name:" +getnature () + ", Color:" +getcolour () + ", Age:" +getage () + ", Attributes:" +getnature () ");
}
Public String GetName () {
return Name;
}
public void SetName (String name) {
name = name;
}
Public String Getcolour () {
return colour;
}
public void Setcolour (String colour) {
Colour = colour;
}
Public String Getage () {
return age;
}
public void Setage (String age) {
Age = age;
}
Public String getnature () {
return Nature;
}
public void Setnature (String nature) {
Nature = Nature;
}


public static void Main (string[] args) {
User Per1=new User ("Wreck", "1");
Per1.print ();
User per2=new User ("Dumb dog", "2");
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 ("User name:" +name+ "\ T" + "Password Password:" +password);
}
public void count () {
System.out.println ("Number of users:" + (count-1));
}
}

Fourth time Java Job

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.