Olá pessoal.
Recebi um exercício do professor, e o único objetivo é fazer compilar o código abaixo:
public class Teste1 {
public static void main ( String args [ ] )
{
try
{
Date birth = new Date(24,7,1949) ;
Date hire = new Date(12,3,1988) ;
Employee employee = new Employee("Bob", "Blue", birth, hire);
}
catch (WrongDateValuesException e )
{
System.out.println(e);
}
System.out.println(employee);
}
}
Gerei as seguintes classes para tentar resolver o problema:
public class Date {
public int day;
public int month;
public int year;
public Date(int day, int month, int year) throws WrongDateValuesException
{
if( day >= 1 && day <= 31 && month >= 1 && month <= 31)
{
throw new WrongDateValuesException();
}
else
{
this.day = day;
this.month = month;
this.year = year;
}
}
public String toString()
{
return ("Eu sou uma data!");
}
}
public class Employee {
public String name;
public String color;
public Date birth;
public Date hire;
public Employee(String name,String color,Date birth,Date hire)
{
this.name = name;
this.color = color;
this.birth = birth;
this.hire = hire;
}
public String toString()
{
return("Eu sou um empregado!");
}
}
public class WrongDateValuesException extends Exception
{
}
Estou usando o Eclipse, cada classe está em um arquivo, tudo mais.
Porém acontece o seguinte: na linha System.out.println(employee);
ocorre o seguinte erro: “employee cannot be resolved”
Alguém poderia me ajudar a detectar os problemas?
Agradeço se puderem ajudar. 