dateclass.cs
// Josh Santomieri
// Santomieri Systems
// http://www.santsys.com

// Programming Windows with C#, Charles Petzold


using System;

class DateClass
{
	public static void main()
	{
		Date myDate = new Date();

		myDate.month = 7;
		myDate.day = 8;
		myDate.year = 1983;

		Console.WriteLine("My B-Day: {0}", myDate.DayOfYear());
	}
}

class Date
{
	public int month;
	public int day;
	public int year;

	public static bool IsLeapYear(int year)
	{
		return (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0));
	}

	public int DayOfYear()
	{
		int[] MonthDays = new int[] { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };

		return MonthDays[month - 1] + day + (month > 2 && IsLeapYear(year) ? 1 : 0);
	}
}