librarytest
Class LibraryDate

java.lang.Object
  extended by librarytest.LibraryDate

public class LibraryDate
extends java.lang.Object

A date class to use for all library activities Has data elements: day (integer), month (integer), year (integer)


Constructor Summary
LibraryDate()
          Default constructor with no inputs that gets the real current date from the OS by using one of the built in date types (e.g., Date, Calendar, GregorianCalendar, …) The Java built-in type should ONLY be used to get the current date to put in the LibraryDate object.
LibraryDate(int day, int month, int year)
          Constructor that accepts an input day, month, and year, error checks these values and stores them in a new LibraryDate object.
 
Method Summary
 LibraryDate addDays(int numdays)
          Add a number of days to the current date
 int getDay()
           
 int getMonth()
           
 int getYear()
           
 int howManyDays()
          Compare two dates and return the number of days between the invoking date and the passed in date
 boolean setDay(int day)
          Error check the value for day based on month and year
 boolean setMonth(int month)
          Error check month value
 boolean setYear(int year)
          Error check year for negative value
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LibraryDate

public LibraryDate()
Default constructor with no inputs that gets the real current date from the OS by using one of the built in date types (e.g., Date, Calendar, GregorianCalendar, …) The Java built-in type should ONLY be used to get the current date to put in the LibraryDate object.


LibraryDate

public LibraryDate(int day,
                   int month,
                   int year)
Constructor that accepts an input day, month, and year, error checks these values and stores them in a new LibraryDate object. For Lab #3, dates must be REAL dates. You may not use the "30-day" simplification.

Parameters:
day -
month -
year -
Method Detail

addDays

public LibraryDate addDays(int numdays)
Add a number of days to the current date

Parameters:
numdays -
Returns:
LibraryDate - future date of today plus numdays

getDay

public int getDay()
Returns:
day value

setDay

public boolean setDay(int day)
Error check the value for day based on month and year

Parameters:
day -
Returns:
boolean - true means day is valid

getMonth

public int getMonth()
Returns:
value of month 1 - 12

setMonth

public boolean setMonth(int month)
Error check month value

Parameters:
month -
Returns:
boolean - true means valid month 1 - 12

getYear

public int getYear()
Returns:
int year

setYear

public boolean setYear(int year)
Error check year for negative value

Parameters:
year -
Returns:
boolean - true means year was positive

howManyDays

public int howManyDays()
Compare two dates and return the number of days between the invoking date and the passed in date

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns: