Java Reference
In-Depth Information
Display 7.2
The Base Class
Employee
(part 2 of 2)
41
/**
42
Precondition newName is not null.
43
*/
44
public
void
setName(String newName)
45
{
46
if
(newName ==
null
)
47
{
48
System.out.println("Fatal Error setting employee name.");
49
System.exit(0);
50
}
51
else
52
name = newName;
53
}
54
/**
55
Precondition newDate is not null.
56
*/
57
public
void
setHireDate(Date newDate)
58
{
59
if
(newDate ==
null
)
60
{
61
System.out.println("Fatal Error setting employee hire date.");
62
System.exit(0);
63
}
64
else
65
hireDate =
new
Date(newDate);
66
}
67
public
String toString()
68
{
69
return
(name + " " + hireDate.toString());
70
}
71
public
boolean
equals(Employee otherEmployee)
72
{
73
return
(name.equals(otherEmployee.name)
74
&& hireDate.equals(otherEmployee.hireDate));
75
}
76
}