c# - A class definition for a date class that contains three integer data members:month,day,year -
i not sure asking here. example great.
here complete list of requirements. working through exercise in book have been reading have read chapter on , on cant make sense out of it.
a class definition date class contains 3 integer data members:month,day,year
one constructor assigns date 1/1/2000 new object not recieve arguments.
- one constructor thats accepts month , day arguements , uses default year of 2004
 - one constructor thats accepts month, day,and year arguements
 - each constructor should output message user stating constructor being used.
 - a method displays values in date object.
 
public class weirdrequirements {     int m_year, m_month, m_day;     public delegate void messageprinter(string message);     public messageprinter printmessage = console.writeline;      public weirdrequirements()     {         m_year = 2000;         m_month = 1;         m_day = 1;         printmessage("default");     }      public weirdrequirements(int month, int day)     {         m_year = 2004;         m_month = month;         m_day = day;         printmessage("int month, int day");     }      public weirdrequirements(int year, int month, int day)     {         m_year = year;         m_month = month;         m_day = day;         printmessage("int year, int month, int day");     }      public void printvalues()     {         printmessage(string.format("year={0} month={1} day={2}", m_year, m_month, m_day));     } }      
Comments
Post a Comment