Very new to programming, only a few weeks into my first Java course. I have looked at similar queries here but the programs in question are a lot more complicated than my simple one so it's hard to make out the solution! I basically have two classes, Dates and DatesTest. I want to input the values in DatesTest and pass them to Dates for printing using Set & Get. Everything is compiling fine but my values are all being printed as zero, can anyone point out what I've missed please?
public class Dates
{
private int dateMonth;
private int dateDay;
private int dateYear;
public Dates( int month , int day , int year)
{
dateMonth = month;
dateDay = day;
dateYear = year;
}
public void setDateMonth( int month )
{
dateMonth = month;
}
public int getDateMonth()
{
return dateMonth;
}
public void setDateDay( int day )
{
dateDay = day;
}
public int getDateDay()
{
return dateDay;
}
public void setDateYear( int year )
{
dateYear = year;
}
public int getDateYear()
{
return dateYear;
}
public void displayDate(int month , int day , int year)
{
System.out.printf("\nToday's date is: %d/%d/%d" , getDateMonth() , getDateDay() , getDateYear() );
}
}//end of class Dates
import java.util.Scanner;
public class DatesTest
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int newMonth = 0;
int newDay = 0;
int newYear = 0;
Dates date1 = new Dates( newMonth , newDay , newYear);
System.out.println("Please enter the current month: ");
newMonth = input.nextInt();
System.out.println("Please enter the current day: ");
newDay = input.nextInt();
System.out.println("Please enter the current year: ");
newYear = input.nextInt();
date1.displayDate(newMonth , newDay , newYear);
}
}//end of class DatesTest