class Baby
{
String name;
private String id;
{
cry();
}
Baby(){
}
Baby(String name)
{
this.name=name;
}
public String setId(String id)
{
this.id=id;
return id;
}
public String getId(S)
{
return id;
}
public void cry(){
System.out.println("婴儿哇哇哭");
}
}
class Hospital
{
private String name;
private String address;
private String tel;
public String getName()
{
return name;
}
public String getAddress()
{
return address;
}
public String getTel()
{
return tel;
}
Hospital(){}
Hospital(String name,String address,String tel)
{
this.name=name;
this.address=address;
this.tel=tel;
}
public Baby setIdentity(Baby b)
{
if (b==null)
{
return null;
}
b.setId("3848848488");
return b;
}
}
class Demo5
{
public static void main(String args[])
{
Hospital hospital=new Hospital("友好医院","太和镇","020-84848484");
Baby b=hospital.setIdentity(new Baby("yy"));
if( b!=null)
{
System.out.print(b.name
+"获取到的身份证"+b.getId());
}
}
} |
|