package meta;
public class BirthDate {
private int day = 1;
private int month = 1;
private int year = 1900;
public BirthDate (int day, int month,int year) {
this.day = day;
this.month = month;
this.year = year;
}
public BirthDate (BirthDate date) {
this.day = date.day;
this.month = date.month;
this.year = date.year;
}
public BirthDate addDays (int add_days) {
BirthDate date1 = new BirthDate (this);
/ / the constructor calls
with this as a parameter.date1.day = date1.day + add_days;
return date1;
}
public static BirthDate addDays2 (BirthDate date1,int add_days) {
date1.day = date1.day + add_days;
return date1;
}
public static void printDate (BirthDate date) {
System.out.println (date.year + "" + date.month + "" + date.day);
}
public static void main (String [] args) {
/ / TODO Auto-generated method stub
BirthDate date0 = new BirthDate (3pm 5J 1988);
printDate (date0);
date0 = date0.addDays (7);
printDate (date0);
date0 = addDays2 (date0,4);
printDate (date0);
}
}
first, what exactly does the constructor public BirthDate (BirthDate date) mean by calling its own class type as a parameter? What is the purpose?
second, BirthDate date1 = new BirthDate (this);. What is the purpose of the this here as a parameter?