3 Week 01 Lab 03 Date W
3 Week 01 Lab 03 Date W
3 Week 01 Lab 03 Date W
Date
Class
Fields
- year : int
- month : int
- day : int
Methods
+ «constructor» Date(
day : int = 1,
month : int = 1,
year : int = 2022)
+ ToString() : string
+ Add(days : int) : void
+ Add(month : int, days : int) : void
+ Add(other : Date) : void
- Normalize() : void
Description of constructor:
1. public Date(int day, int month, int year): this is the constructor of this class. It
takes three integer arguments and assigns them to the appropriate fields. You will assume that
all the arguments will be in the correct range.
This method should be called at the end of the constructor, and each Add method.
Enhancements:
1. Display the text for the month i.e. Jan or January for the month 1.
2. Handle the different month length properly
"30 days has September, April, June, and November. All the rest have 31. Save
February, with 28 days clear, and 29 each leap year."
3. Would it be better to have a single int field that represents the number of days passed since the
year has started? Now all the operations are easier to implement excepting the ToString
method.