Example 2 (2)
Class declaration (continued):
public void advance (int n) { // Advance this date by n days (where n = 0). int y = this.y, m = this.m, d = this.d + n; for (;;) { int last = …; // no. of days in m, y if (d <= last) break; d -= last; if (m < 12) m++; else { m = 1; y++; } } this.y = y; this.m = m; this.d = d; }