I have two classes (Date and Employee).
Class Date doesn't have a constructor, but it has 3 variables with their setters.
Class Employee has a constructor where I initialized its variables. But I have to attach the 3 variables in Class Date to it.
I tried using Setter method, but when I run the code, it says that there's an error with:
hire_date.setDay(1);
hire_date.setMonth(1);
hire_date.setYear(2018);
//In class Empolyee
private String name;
private Date hire_date;
private double monthly_salary;
public Employee() {
name = "Jody";
hire_date.setDay(1);
hire_date.setMonth(1);
hire_date.setYear(2018);
monthly_salary = 2000.0;
}
//In class Date
private int day;
private int month;
private int year;
public void setDay(int day) {
this.day = day;
}
public void setMonth(int month) {
this.month = month;
}
public void setYear(int year) {
this.year = year;
}