Question
Create a file named A6.java. Place all code in this file. In Java, write a class definition for Date, an object type that contains three
Create a file named A6.java. Place all code in this file.
In Java, write a class definition for Date, an object type that contains three private field integers: year, month, and day. This class should provide two constructors. The first should take no parameters and initialize a default date (12/30/2020). The second should take parameters named day, month and year, and use them to initialize the instance variables. Write getters and setters for year, month, and day (getYear, setYear, getMonth, setMonth, getDay, setDay). Implement the toString and equals methods. The toString method should output the date in American date format (e.g. year = 2020, month = 12, day = 10 should output 12/10/2020).
Hint: To add a class to a file with a different name, you can remove public from your new classs definition. For example: public class A6 { } class Date { // Dates implementation }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started