The dateTimeInherit
class is an inherited class from dateTimeAbstract
so it must use the daysOfAnyMonth
method. I was thinking of using some classes from the YearMonth
and LocalDate
classes but was not sure where to go from there.
import java.io.IOException;
public class Driver
{
public static void main(String[] args) throws IOException
{
DateTimeInherit dateTimeInherit = new DateTimeInherit();
/**
* From the given line of codes you have to identify the class name and necessary
constructors/methods
* In the following method, the first parameter is the month and the second parameter is the
year.
* We are going to print the first day and the last day (day of the week) of any given month of
the year.
* Output format: for (4, 2020):
* In the year 2020, for the 4th month: the first day is WEDNESDAY and the last day is
THURSDAY
*/
dateTimeInherit.daysOfAnyMonth(9, 2020);
dateTimeInherit.daysOfAnyMonth(10, 2020);
dateTimeInherit.daysOfAnyMonth(12, 2020);
System.out.print("\n");
public abstract class DateTimeAbstract
{
abstract void daysOfAnyMonth(int monthOfYear, int theYear);
}
import java.util.Calendar;
public class DateTimeInherit extends DateTimeAbstract
{
// Method that needs to be written
}
Calendar
class when implementing this task? Or you can use newer Java Time API? – Whorl