Task 1: Explore the Employer Class
Employer file in IntelliJ and examine the code. In addition to the two fields—
value—the class includes the standard getters and setters as well as some custom methods like
You can refer to these examples as you fill in the missing pieces in the other classes, but for now let’s take a closer look at the constructors.
Assign a Unique ID
One neat trick we can use is to automatically assign each new object a unique ID number.
Examine the two constructors in
Line 3 declares the variable
nextId. Since it is
static, its changing value is NOT stored within any
The first constructor (lines 6 - 9) accepts no arguments and assigns the value of
nextIdto the id field. It then increments
nextId. Thus, every new
Employerobject will get a different ID number.
The second constructor (lines 11 - 14) assigns
valuefield. However, it ALSO initializes
idfor the object by calling the first constructor with the
Employerconstructor makes initializing id a default behavior.