Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    The class Person which calls DayDifference on dateOfBirth.Lecture 5 - slide 22 : 29
Program 2
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.