public class Person{
private string name;
private Date dateOfBirth, dateOfDeath;
public Person (string name, Date dateOfBirth){
this.name = name;
this.dateOfBirth = dateOfBirth;
this.dateOfDeath = null;
}
public string Name{
get {return name;}
}
public Date DateOfBirth{
get {return dateOfBirth;}
}
public int DayAge(){
return new Date(2008, 3, 11).DayDifference(dateOfBirth);
}
public override string ToString(){
return "Person: " + name + " " + dateOfBirth;
}
} | |
We pass a reference to a Date object to DayDifference.
This mutates the referenced date object.
|