Date - //according to the parameters. //Postcondition:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Date { private int dMonth; //variable to store the month private int dDay; //variable to store the day private int dYear; //variable to store the year //Default constructor //The instance variables dMonth, dDay, and dYear are set to //the default values. //Postcondition: dMonth = 1; dDay = 1; dYear = 1900; public Date() { dMonth = 1; dDay = 1; dYear = 1900; } //Constructor to set the date //The instance variables dMonth, dDay, and dYear are set //according to the parameters. //Postcondition: dMonth = month; dDay = day; // dYear = year; public Date(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; } //Method to set the date //The instance variables dMonth, dDay, and dYear are set
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //according to the parameters. //Postcondition: dMonth = month; dDay = day; // dYear = year; public void setDate(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; } //Method to return the month //Postcondition: The value of dMonth is returned. public int getMonth() { return dMonth; } //Method to return the day //Postcondition: The value of dDay is returned. public int getDay() { return dDay; } //Method to return the year //Postcondition: The value of dYear is returned. public int getYear() { return dYear; } //Method to return the date in the form mm-dd-yyyy public String toString() { return (dMonth + "-" + dDay + "-" + dYear); } }...
View Full Document

Page1 / 2

Date - //according to the parameters. //Postcondition:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online