Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a class named Employee that has the following fields or attributes: ld: an int variable that holds the employee's ID number name: the employee's
Write a class named Employee that has the following fields or attributes: ld: an int variable that holds the employee's ID number name: the employee's name department: the name of the department where the employee works. position: a String object that holds the employee's job title . The class should have the following constructors: A constructor that accepts the employee's ID, name, department, and position as arguments and assigns them to the appropriate fields: constructor that accepts the employee's ID and name as arguments and assigns them to the appropriate fields; empty strings(") are assigned to department and position A no-argument constructor that assigns empty strings(") to the name, department, and position fields, and 0 to the ID field A The class should have the appropriate mutator (setter) methods that store values in these fields and accessor (getter) methods that return the values in these fields. It should also define a method named toString0 that takes no argument and and uses String.format. to return a string containing the fields (id, name, department and position) of the employee object in a format of your choosing Write a separate driver program to test this class. This program should create an arraylist of Employee objects. It should use the three constructors to create three Employee objects (one per each constructor) based on the following information and add them to the arraylist. ID 891252 850656 864358 NAME Jonathan Rogers Mark Adams Susan Jones DEPARTMENT Customer Services Human Resources Admission Office POSITION System Analyst Benefits Manager Record Clerk On employee objects with attributes initialized to 0 or empty strings() by their constructors, your program should call their appropriate setter functions to provide the actual values of these attributes from the above table
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started