Ok So I have to create a Date Class that will allow me to return the current day with data members of month , day, and year

this is what I have for from my Main() class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DateApp2
{
    class DateApp
    {
        static void Main();
        {   
            DateApp date1 = 
                 new DateApp (10, 31, 2011, "10/31/11");
            Console.Write (date1);
        }
        
        public static void DisplayResults(DateApp someDate)
        {
              Console.Clear();
              Console.WriteLine("Current Date: " + someDate.CalculateDate().ToString("F1");
                                
                                
        }   
            
       
        } // end of Main
    } // end of DateApp Class
} //end of namespace

and this is what I have from my "Date Class(helper/worker)" :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DateApp2
{
    class Date
    {
        private int monthDate;
        private int dayDate;
        private int yearDate;
        private string currentDate;
    } // end of Date Class

    public int MonthDate
    {
        get 
        {
            return monthDate;
        }
         set  
        {
            monthDate = value ; 
        }
    }

    public int DayDate 
    {
        get
        {
            return dayDate;
        }
            set 
        {
                dayDate = value;
        }
    }

    public int YearDate
    {
        get
        {
            return yearDate;
        }
            set
        {
                yearDate = value;
        }
     }
    
    public string CurrentDate
    {
        get 
        {
            return currentDate;
        } 
            set 
        {
                currentDate = value;
        }
    }

     //default constructor
    public Date()
    {

    }

    public Date(int month, int day, int year , string current)

    {
        monthDate = month;
        dayDate = day;
        yearDate = year;
        currentDate = current;
    } 

    public Date (int month , int day , int year)
    {
        monthDate = month;
        dayDate = day;
        yearDate= year;
    }

    public Date (string today)
    {
         currentDate = today;
    }

    public CalculateDate()
    {
       return int monthDate, int dayDate, int yearDate
    }

    public override string ToString()
    {
        return string.Format ("{0,20}", "Date App") +
                              "\n\nMonth: " + monthDate +
                              "\n\nDay: " + dayDate +
                              "\n\nYear: " + yearDate +
                              "\n\nCurrent Date: " + CalculateDate().ToString("F1");
    }
   
} // end namespace

:( Im going crazy with this..mainly for the fact its a new section...please help

These are the errors I have:

Error 17 'DateApp2.DateApp' does not contain a constructor that takes 4 arguments 13 18 DateApp2
Error 19 'DateApp2.DateApp.date1' is a 'field' but is used like a 'type' 14 28 DateApp2
Error 18 'System.Console.Write(string)' is a 'method' but is used like a 'type' 14 21 DateApp2
Error 4 Expected class, delegate, enum, interface, or struct 17 23 DateApp2
Error 7 Expected class, delegate, enum, interface, or struct 16 12 DateApp2
Error 8 Expected class, delegate, enum, interface, or struct 28 12 DateApp2
Error 9 Expected class, delegate, enum, interface, or struct 40 12 DateApp2
Error 10 Expected class, delegate, enum, interface, or struct 52 12 DateApp2
Error 11 Expected class, delegate, enum, interface, or struct 65 12 DateApp2
Error 12 Expected class, delegate, enum, interface, or struct 70 12 DateApp2
Error 13 Expected class, delegate, enum, interface, or struct 79 12 DateApp2
Error 14 Expected class, delegate, enum, interface, or struct 86 12 DateApp2
Error 15 Expected class, delegate, enum, interface, or struct 91 12 DateApp2
Error 16 Expected class, delegate, enum, interface, or struct 96 21 DateApp2
Error 2 Invalid token '(' in class, struct, or interface member declaration 14 27 DateApp2
Error 3 Invalid token ')' in class, struct, or interface member declaration 14 33 DateApp2
Error 1 Invalid token '{' in class, struct, or interface member declaration 11 9 DateApp2
Error 5 Type or namespace definition, or end-of-file expected 27 5 DateApp2
Error 6 Type or namespace definition, or end-of-file expected 28 1 DateApp2

UPDATE************* Ok I figured out view issues I reduced the errors down to 10. But now Im really royally stuck :(

here is the helper/worker class "Date":

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DateApp2
{
    class Date
    {
        private int monthDate;
        private int dayDate;
        private int yearDate;
        private string currentDate;
     // end of Date Class

    public int MonthDate
    {
        get 
        {
            return monthDate;
        }
         set  
        {
            monthDate = value ; 
        }
    }

    public int DayDate 
    {
        get
        {
            return dayDate;
        }
            set 
        {
                dayDate = value;
        }
    }

    public int YearDate
    {
        get
        {
            return yearDate;
        }
            set
        {
                yearDate = value;
        }
     }
    
    public string CurrentDate
    {
        get 
        {
            return currentDate;
        } 
            set 
        {
                currentDate = value;
        }
    }

     //default constructor
    public Date()
    {

    }

    public Date(int month, int day, int year , string current)

    {
        monthDate = month;
        dayDate = day;
        yearDate = year;
        currentDate = current;
    } 

    public Date (int month , int day , int year)
    {
        monthDate = month;
        dayDate = day;
        yearDate= year;
    }

    public Date (string today)
    {
         currentDate = today;
    }

    public string CalculateDate()
    {
        return currentDate;
    }

    public override string ToString()
    {
        return string.Format ("{0,20}", "Date App") +
                              "\n\nMonth: " + monthDate +
                              "\n\nDay: " + dayDate +
                              "\n\nYear: " + yearDate +
                              "\n\nCurrent Date: " + currentDate.ToString("F1");
    } //end of ToString method
   
    } // end of class "Date"
} //end of namespace

and here is the Main() class DateApp:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DateApp2
{
    class DateApp
    {
        static void Main();
        {   
            DateApp date1 = 
                 new DateApp (10, 31, 2011, "10/31/11");
            Console.Write (date1);
        } //end of main
        
        public static void DisplayResults(DateApp someDate)
        {
              Console.Clear();
              Console.WriteLine("Current Date: " + someDate.CalculateDate().ToString("F1");
                                
                                
        }   //end of DisplayResults
            
       
        } // end of class DateApp
 } // end of Namespace

New list of errors

Error 6 'DateApp2.DateApp' does not contain a constructor that takes 4 arguments 13 18 DateApp2
Error 8 'DateApp2.DateApp.date1' is a 'field' but is used like a 'type' 14 28 DateApp2
Error 7 'System.Console.Write(string)' is a 'method' but is used like a 'type' 14 21 DateApp2
Error 10 Argument 1: cannot convert from 'string' to 'System.IFormatProvider' 102 75 DateApp2
Error 4 Expected class, delegate, enum, interface, or struct 17 23 DateApp2
Error 2 Invalid token '(' in class, struct, or interface member declaration 14 27 DateApp2
Error 3 Invalid token ')' in class, struct, or interface member declaration 14 33 DateApp2
Error 1 Invalid token '{' in class, struct, or interface member declaration 11 9 DateApp2
Error 9 The best overloaded method match for 'string.ToString(System.IFormatProvider)' has some invalid arguments 102 54 DateApp2
Error 5 Type or namespace definition, or end-of-file expected 27 2 DateApp2

The main.

namespace DateApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            ClsDate objDate = new ClsDate(10, 31, 2011, "10/31/11");
            objDate.showDate();

            //Console.WriteLine(objDate.ToString());
            Console.Read();
            
        }
    }//Fin cls.
}

External class.

namespace DateApp2
{
    class ClsDate
    {
        #region datamembres
            private int monthDate;
            private int dayDate;
            private int yearDate;
            private string currentDate;
        #endregion

        #region proprietes
            public int MonthDate
            {
                get{return monthDate;}
                set{monthDate = value ;}
            }

            public int DayDate
            {
                get{return dayDate;}
                set{dayDate = value;}
            }
 
            public int YearDate
            {
                get{return yearDate;}
                set{yearDate = value;}
            }
 
            public string CurrentDate
            {
                get{return currentDate;}
                set{currentDate = value;}
            }
        #endregion

        #region methodes
            public ClsDate(int month, int day, int year, string current) //Ctor
            {
                monthDate = month;
                dayDate = day;
                yearDate = year;
                currentDate = current;
            }
 
            public void showDate()
            {
                Console.WriteLine("/* Date App. */\n" + "Month: " + MonthDate + "\nDay: " + DayDate + "\nYear: " + YearDate + "\n\nCurrent Date: " + CurrentDate);
            }
        #endregion
    }// Fin cls.
}

For Error6:

DateApp date1 = new DateApp (10, 31, 2011, "10/31/11");

You have used this to create object for class DateApp,and passed four arguments, but you don't have a constructor for the class DateApp.

For Error 7 and 8:

Console.Write (date1);

You can't print an object, rather you can print string,int.

And there are many syntax errors, try to find it

Edited 5 Years Ago by samueal: n/a

Thanks to Samueal for his explanations. Sorry, i don't give any explications for my code.

Edited 5 Years Ago by Kohai: n/a

This article has been dead for over six months. Start a new discussion instead.