In this assignment, you will need to add a new method to the Date class, which you can find on D2L in the "Sample Code" section. The new method should make a Date object's day, month, and year value change to the next day. In other words, add one day to the object's current date. Do not use any part of the built-in DateTime class, but you may want to use the DaysInMonth() method from the Date class. Examples: • If the Date object stores the date 12/31/2021, then after calling your method it should store the date 1/1/2022 • If the Date object stores the date 2/28/2022, then after calling your method it should store the date 3/1/2022 As noted in the common instructions, you only need to turn in your new method, not the entire Date class.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
In this assignment, you will need to add a new method to the Date class, which you
can find on D2L in the "Sample Code" section.
The new method should make a Date object's day, month, and year value change to
the next day. In other words, add one day to the object's current date. Do not use any
part of the built-in DateTime class, but you may want to use the DaysInMonth()
method from the Date class.
Examples:
• If the Date object stores the date 12/31/2021, then after calling your method
it should store the date 1/1/2022
• If the Date object stores the date 2/28/2022, then after calling your method it
should store the date 3/1/2022
As noted in the common instructions, you only need to turn in your new method, not
the entire Date class.
Transcribed Image Text:In this assignment, you will need to add a new method to the Date class, which you can find on D2L in the "Sample Code" section. The new method should make a Date object's day, month, and year value change to the next day. In other words, add one day to the object's current date. Do not use any part of the built-in DateTime class, but you may want to use the DaysInMonth() method from the Date class. Examples: • If the Date object stores the date 12/31/2021, then after calling your method it should store the date 1/1/2022 • If the Date object stores the date 2/28/2022, then after calling your method it should store the date 3/1/2022 As noted in the common instructions, you only need to turn in your new method, not the entire Date class.
using System;
using System.Text;
namespace DatePrj
{
}
public class Date
{
private int day;
public int Day
{
}
get
{
}
set
{
}
}
private int month;
public int Month
{
{
}
set
return this.day;
h
if ((value> ) && (value <= DaysInMonth()))
this.day value;
{
else // do not use Console always throw
throw new ArgumentException("Invalid value for Date's Day:" + value);
}
return this month;
}
}
public int Year { get; set; }
if ((value > 0) && (value < 13))
this month= value;
else
throw new ArgumentException("Invalid value for Date's Month: + value);
public void set(int day, int month, int year)
{
}
public Date()
{
set (DateTime.Now.Day, DateTime.Now.Month, DateTime.Now. Year);
// use error checking in each property and ensure Month is set before Day
this. Year = year;
this.Month = month;
this.Day = day;
public Date(int aMonth, int aDay, int aYear)
{
// use error checking in each property
set (aDay, aMonth, aYear);
}
public int DaysInMonth()
{
int Days = 31;
switch (Month)
{
case 4:
case 6:
case 9:
case 11:
Days = 30;
break;
case 2:
if (((Year % 4 == 0) && (Year % 100) != 0) || (Year % 400 == 0))
Days = 29;
else
Days = 28;
break;
}
return Days;
}
public override string ToString()
{
return Month + "/" + Day + "/" + Year;
Transcribed Image Text:using System; using System.Text; namespace DatePrj { } public class Date { private int day; public int Day { } get { } set { } } private int month; public int Month { { } set return this.day; h if ((value> ) && (value <= DaysInMonth())) this.day value; { else // do not use Console always throw throw new ArgumentException("Invalid value for Date's Day:" + value); } return this month; } } public int Year { get; set; } if ((value > 0) && (value < 13)) this month= value; else throw new ArgumentException("Invalid value for Date's Month: + value); public void set(int day, int month, int year) { } public Date() { set (DateTime.Now.Day, DateTime.Now.Month, DateTime.Now. Year); // use error checking in each property and ensure Month is set before Day this. Year = year; this.Month = month; this.Day = day; public Date(int aMonth, int aDay, int aYear) { // use error checking in each property set (aDay, aMonth, aYear); } public int DaysInMonth() { int Days = 31; switch (Month) { case 4: case 6: case 9: case 11: Days = 30; break; case 2: if (((Year % 4 == 0) && (Year % 100) != 0) || (Year % 400 == 0)) Days = 29; else Days = 28; break; } return Days; } public override string ToString() { return Month + "/" + Day + "/" + Year;
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education