Explore BrainMass
Share

Java Creating a Class Called Date

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

Create a class called SimpleDate that includes three instance variables - a month, a day and a year (all type int). Provide a constructor that initializes the three instance variables and validates that those values are correct (follow calendar rules) and throws an exception for incorrect values. Provide a set and get method for each instance variable. Provide a toString method override that displays the month, day and year separated by forward slashes (/).
Write a test application named SimpleDateTest that demonstrates class SimpleDate's capabilities

© BrainMass Inc. brainmass.com September 21, 2018, 11:16 pm ad1c9bdddf - https://brainmass.com/computer-science/java/java-creating-class-called-date-481919

Solution Summary

This solution helps create a class called SimpleDate, which includes three instance variables (month, day and year). It also provides a constructor that initializes the three initializes three instance variables and validates that those values are correct. It also provides a set and get method for each instance variable and a toString method to override the display. In addition, a test application named SimpleDateTest demonstrating SimpleDate's capabilities is given.

$2.19