please do in C# console application. not any other language create a Date class
ID: 3776020 • Letter: P
Question
please do in C# console application. not any other language
create a Date class with integer data members or year, month, and day. Also include string data part member for the name of te month Include method that returns the month name (as a string as of the date. Separate the day from year with a comma in that method, include approprate the constructors, properties, and methods, override the Tostring ethod to display the date formanted with slashes separating the month, day. and year create a second class that instantiates and test the Date class.Explanation / Answer
Date.cs file
using System.IO;
using System;
class Date
{
int year;
int month;
int day;
string monthname;
public Date(int y,int m,int d,string name){
year = y;
month = m;
day = d;
monthname = name;
}
public string GetMonthName(){
return ""+day+","+monthname+","+year;
}
public override string ToString(){
string s = year + "/" + month + "/" + day;
return s;
}
}
Program.cs file
using System.IO;
using System;
class Program
{
static void Main()
{
Date d = new Date(16,11,22,"Nov");
Console.WriteLine(d.ToString());
Console.WriteLine(d.GetMonthName());
}
}
/* sample output
16/11/22
22,Nov,16
*/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.