class Date { 

   private int day, month, year; // the date
    
   Date(int d, int m, int y){
	   day = d; month = m; year = y;
   }

   Date(){ };

   void get() {
	   day = Console.readInt(); month = Console.readInt(); year = Console.readInt();
   }

  void put(){
	  System.out.println(day + "/" + month + "/" + year);

  private int elapsedDays() {
  // The number of days elapsed from 1/1/1900 to this date
    int days = (year-1900)*365+(year-1901)/4; 
    int k = 1;
    while (k<month) {
	int daysInMonth;
	if (k==9||k==4||k==6||k==11) 
		daysInMonth = 30;
	else if (k==2) {
		if (year%4==0 && year!=1900) daysInMonth = 29;
		else daysInMonth = 28;
	}
	else daysInMonth = 31;
      days = days + daysInMonth; 
      k++; 
    }
    return days + day;
  }
   
   boolean postDates(Date d) {
	  // Does this date occur on or after d?
    .....
  }
}

my mind has gone completely blank with the boolean method postDates would appreciate a bit of help!!

You just need to compare the year/month/day (in that order) from the current date and the date that's passed as a parameter

Thanks James that method works but I think we have to use the elapsedDays method to solve it. I can't seem to get it to work with the boolean method.

OK, you didn't say that before.
If you use elapsedDays then it's really easy. Whichever date has the highest elapsedDays is the later of the two.

boolean postDates(Date d) {
	   Date e = new Date();
	   return (e.elapsedDays() > d.elapsedDays());
}

I know theirs an easy answer I just can't seem to get it working

You don't want to create a new Date to compare to "d". You want to use the current instance value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.