May 2008
Beginner
550 pages
13h 22m
English
Now let's use some of our design ideas to implement the design for clsDates. The code for clsDates is shown in Listing 9-4.
using System;
using System.Collections.Generic;
using System.Text;
public class clsDates
{
// =============== symbolic constants ==================
// =============== static members ======================
private static int[] daysInMonth = { 0, 31, 28, 31, 30, 31, 30, 31,
31, 30, 31, 30, 31};
// =============== instance members =====================
private int day;
private int month;
private int year;
private int leapYear;
private DateTime current;
// =============== constructor(s) ======================
public clsDates()
{
current = DateTime.Now; // Sets DateTime to right now
}
// =============== property methods =====================
// =============== helper methods =======================
// =============== general methods ======================
/*****
* Purpose: To determine if the year is a leap year. Algorithm
* taken from C Programmer's Toolkit, Purdum, Que Corp.,
* 1993, p. 258.
*
* Parameter list:
* int year the year under consideration
*
* Return value:
* int 1 if a leap year, 0 otherwise
*****/
public int getLeapYear(int year)
{ if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return 1; // It is a leap year else return 0; // Nope. } /***** * Purpose: To determine the date for Easter given a year. Algorithm * taken from C Programmer's Toolkit, Purdum, Que Corp., * 1993, p. 267. * * Parameter ... |