📄 people.java
字号:
import Mypackage.NewDate; //引用Mypackage包中的NewDate类
public class People
{
private String name;
private NewDate birth;
public static void main(String args[])
{
People a = new People("Wangli",1981,2,14);
a.output();
}
public People(String n1,NewDate d1)
{
name = n1;
birth = d1;
}
public People(String n1,int y,int m,int d)
{
this(n1,new NewDate(y,m,d));
}
public People()
{
this("",new NewDate());
}
public int age() //计算年龄
{
return NewDate.thisyear() - birth.year(); //获得年份
}
public void output()
{
System.out.println("name : "+name);
System.out.println("birth: "+birth.toString());
System.out.println("age : "+age());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -