Question: You have been provided with two classes, a Runner class with a main method that you can use to test your code, and the

You have been provided with two classes, a Runner class with a main method that you can use to test your code, and thescaffold of a Date class. The date class includes three private intdata members called day, month and year. Your task is to completethe Date class according to the following functionality requirements: A constructor that

You have been provided with two classes, a Runner class with a main method that you can use to test your code, and the scaffold of a Date class. The date class includes three private int data members called day, month and year. Your task is to complete the Date class according to the following functionality requirements: A constructor that takes no parameters and sets the day to 1, month to 1 and year to 1901. A constructor that takes three int parameters and sets the day to the first parameter, the month to the second parameter and the year to the third parameter. A getDay method that returns the day. A getMonth method that returns the month. A getYear method that returns the year. A toString method that returns a String in the following format: / / Description For example, if I was to run the following code in the main method in the Runner class: Date d1 = new Date(); System.out.println(d1.getDay()); System.out.println(dl.getMonth()); System.out.println(dl.getYear()); System.out.println(d1); I would expect the following output to be printed to the console: 1 1 1901 1/1/1901 If I was to run the following code in the main method: Date d2 = new Date (19, 10, 2022); System.out.println(d2.getDay()); System.out.println(d2.getMonth()); System.out.println(d2.getYear()); System.out.println(d2); Workspace I would expect the following output to be printed to the console: 19 10 2022 19/10/2022 2 34567820 1234567 9 10 11 + Runner.java 1 public class Runner { 17 } Date.java public static void main(String[] args) { } // You can use the main method to test your class. // Date d1 = new Date(); // System.out.println(d1.getDay()); // System.out.println(d1.getMonth()); // System.out.println(d1.getYear()); // System.out.println(d1); // Date d2 = new Date (19, 10, 2022); // System.out.println(d2.getDay()); // System.out.println(d2.getMonth()); // System.out.println(d2.getYear()); // System.out.println(d2); /home/Runner.java Spaces: 4 (Auto) Console [] All changes saved Run Mark + Runner.java 1 public class Date { 2 3 private int day%;B 4 private int month; Date.java 56982 7 91 private int year; // Complete this class according the functionality requirements. /home/Date.java Spaces: 4 (Auto) Console All changes saved Run Mark *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is the completed Date class based on the requirements provided public class Date Private data m... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!