tags:

views:

69

answers:

1

Possible Duplicate:
A class definition for a date class that contains three integer data members:month,day,year

I am not sure what they are asking for here. An example would be great.

Here is the complete list of requirements. I am working through an exercise in a book I have been reading but I have read the chapter over and over but I just cant make sense out of it.

1.A class definition for a date class that contains three integer data members:month,day,year

2.One constructor that assigns the date 1/1/2000 to any new object that does not recieve any arguments.

3.One constructor thats accepts month and day arguements and uses a default year of 2004
4.One constructor thats accepts month, day,and year arguements
5.Each constructor should also output a message to the user stating which constructor is currently being used.
6.A method that displays the values in the date object
+1  A: 

1

public class myDate
{
  public int day {get;set;}
  public int month {get;set;}
  public int year {get;set;}
}

2

public myDate()
{
  this.day = 1;
  this.month = 1;
  this.year = 2000;
}

3

public myDate(int day, int month)
{
  this.day = day;
  this.month = month;
  this.year = 2004;
}

4

public myDate(int day, int month, int year)
{
  this.day = day;
  this.month = month;
  this.year = year;
}

6

  public DateTime getDate()
  {
    return new DateTime(this.year, this.month, this.day);
  }
griegs
you forgot the constructors ;)
Muad'Dib