Class Address
{Private String country;
Private String Province;
Private String City;
Private String Street;
Private String ZipCode;
Public Address (String country,string province,string city,string street,string zipcode)
{
This.country=country;
This.province=province;
this.city=city;
This.street=street;
This.zipcode=zipcode;
}
Public String Getcountry ()
{
return this.country;
}
public void Setcountry (String country)
{
This.country=country;
}
Public String getprovince ()
{
return province;
}
public void Setprovince (String province)
{
This.province=province;
}
Public String getcity ()
{
return city;
}
public void Setcity (String city)
{
this.city=city;
}
Public String Getstreet ()
{
Return Street;
}
public void Setstreet (String Street)
{
This.street=street;
}
Public String Getzipcode ()
{
return zipcode;
}
public void Setzipcode (String zipcode)
{
This.zipcode=zipcode;
}
public void print ()
{
System.out.println ("Country:" +this.country+ "\ n" + "province:" +this.province+ "\ n" + "City:" +this.city+ "\ n" + "street:" +this.street+ "\ n "+" ZIP Code: "+zipcode";
}
}
public class Test01
{
public static void Main (String args[])
{
Address Add=new address ("China", "Beijing", "Beijing", "Niu Fu Lu", "101301");
Add.print ();
}
}
Class Employee
{
private String number;
private String name;
private int salary;
private int increase;
Public Employee (String number,string name,int salary,int Increase)
{
This.number=number;
This.name=name;
This.salary=salary;
This.increase=increase;
}
Public String GetNumber ()
{
return number;
}
public void Setnumber (String number)
{
This.number=number;
}
Public String GetName ()
{
return name;
}
public void SetName (String name)
{
This.name=name;
}
public int getsalary ()
{
return salary;
}
public void setsalary (int salary)
{
This.salary=salary;
}
public int getincrease ()
{
return increase;
}
public void setincrease (int increase)
{
This.increase=increase;
}
public int sum ()
{
return salary+increase;
}
public void print ()
{
System.out.print ("Employee Number:" +this.number+ "\ n" + "Employee Name:" +this.name+ "\ n" + "base salary:" +this.salary+ "\ n" + "Total Salary:" +this.sum ());
}
}
public class Test02
{
public static void Main (String args[])
{
Employee Emp=new Employee ("01", "Xiaoming", 6000,290);//
Emp.print ();
}
}
Class Dog
{
private String name;
Private String colour;
private int age;
Public Dog (String name,string colour,int age)
{
This.name=name;
This.colour=colour;
This.age=age;
}
public void print ()
{
System.out.println ("Name:" +this.name+ "\ n" + "COLOR:" +this.colour+ "\ n" + "Age:" +this.age);
}
}
Class Test03
{
public static void Main (String args[])
{
Dog Dog=new Dog ("White", "Black", 2);
Dog.print ();
}
}
Class User
{
private String name;
private String password;
private static int count=0;
Public User ()
{
count++;
}
Public User (String name)
{
count++;
This.name=name;
}
Public User (String name,string password)
{
count++;
This.name=name;
This.password=password;
}
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 void print ()
{
System.out.println ("Number of users:" +count);
System.out.println ("User name:" +this.name+ "\ T" + "Password:" +this.password);
}
}
public class Test04
{
public static void Main (String args[])
{
User User1=new user ();
User1.print ();
User User2=new User ("eldest brother");
User2.print ();
User User3=new User ("two elder brother", "haha");
User3.print ();
}
}
3.20 Java