/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package lab2stuff; /** * * @author jcmt */ public class LibraryDate { private int day; private int month; private int year; public LibraryDate() { // Ask the user for current date // So default value for a date should be // current date. } public LibraryDate(int d, int m, int y) { if (!(setDay(d))) day = 10; //ask for a new day or //put in current day } public boolean setDay(int d) { if ((d > 0) && (d < 31) ) { day = d; return true; } return false; } public int compareDates(LibraryDate dt) { // returns a number of days // +pos means not due yet // -neg means overdue /* int dtm = dt.month * 30; // month-1 ? dtm = dtm + dt.day; int cur = month * 30; cur = cur + day; return dtm - cur; */ // compare months /* * if (month == dt.month) return dt.day - day; if () */ int sm = dt.month - month; int sd = dt.day - day; return (sm * 30) + sd; //return 0; } }