Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program for managing an employee database. The required functionality is: 1) An Employee2 class, with the following methods and attributes: a) Data members:

Create a program for managing an employee database. The required functionality is:

1) An Employee2 class, with the following methods and attributes:

a) Data members: firstName (String), lastName (String), ssn (long), employeeId (int), department (String), and jobTitle (String).

b) Constructor methods:

One method requiring parameters for firstName, lastName, ssn, and employeeId. Department and jobTitle will be assigned default values of unknown.

One method requiring parameters for firstName, lastName, ssn, employeeId, department, and jobTitle

c) Set methods for changing firstName, lastName, department, and jobTitle which accept a single String as a parameter for updating the preexisting String.

d) Get methods for returning each of the attributes in 1a.

2) A Controller2_abcde123 class to manage the addition, updating, and viewing of employees

a) Data members:

An array of Employee objects named e, just declared (not created)

An int variable named counter (for the number of employees), initialized to zero

A Scanner object named scanner for text input

b) A getInput method containing a loop for repeatedly receiving text input via scanner. Prior to receiving each input, the program will display the prompt please enter your action. The following inputs will be accepted and the program will respond with:

add: respond with please enter employee data

delete: respond with delete which employee(s)?

update employee: respond with update which employee(s)?

update field values: respond with update which field values?

read: respond with read which employee(s)?

exit: respond with thank you for using the EDB application!

c) Other than exit, the response text will be followed by an empty line and a repeat prompt. The exit command will exit the program by calling System.exit(0).

d) Controller will have a main method that creates a Controller object named c and calls cs getInput method.

The program should be implemented as a single file containing the 2 Java classes Controller and Employee. All data members should be declared as private; all methods should be declared without any visibility modifiers. It is not necessary to provide error-checking for this application; you may safely assume that the user will only enter valid inputs. However, please carefully follow the formats given; points will be deducted for non-standard input formats.

3) For Employee, add set methods for ssn and employeeId.

4) For the Controller class generally:

a) The constructor should create the Employee array e initial size zero.

b) Data fields in Employee objects should be assigned new values using the corresponding set methods and read them using the corresponding get methods.

c) Write a method ePlus that accepts the Employee array e as a parameter and returns an Employee array. The returned array should be one element larger than e and contain all elements of e in the same indexes. To expand e, use: e = ePlus(e);.

d) Write a method eMinus that accepts an int index as a parameter and returns an Employee array. The returned array should be one element smaller than e and without the element at index index. The elements in the returned array should otherwise maintain the same order as in e. To delete an element at index index, use: e = eMinus(index);.

5) In the Controller getInput method, write a method for each valid command:

a) add: increases the size of e by one by calling ePlus, then creates a new Employee object and adds it to the last valid index of e. To create the Employee object, the application will prompt the user to enter values for each of the six Employee data fields, in order: employeeId, lastName, firstName, department, jobTitle, and ssn. The full set of data fields will all be entered on one line, separated by single spaces, and parsed by a StringTokenizer object.

b) delete: decreases the size of e by one. The user will be prompted to enter an index value, then delete that index by calling eMinus

c) update employee: the user will be prompted for an index value, then display via the console the Employee fields for e[index], separated by tabs (\t), in order: employeeId, lastName, firstName, department, jobTitle, and ssn. Then, the user will be prompted to enter a new set of six data values in the same order. As in 4a), The full set of data fields will all be entered on one line, separated by single spaces, and parsed by a StringTokenizer object.

d) update field values: the user will be prompted to enter either department or jobTitle, then an old value String, then a new value String, all on one line, separated by spaces, and parsed by a StringTokenizer object. Within the entered field, any Strings matching the old value will be updated to the new value. For example, if the user enters jobTitle intern associate, then any Employee objects where jobTitle is intern will have that data field changed to associate.

e) read: On the console, the application will display one line for each Employee in e. The Employee objects will be ordered by index, and each line will contain, separated by tabs (\t), in order: the index, employeeId, lastName, firstName, department, jobTitle, and ssn.

f) exit: displays a message via the console, Thank you for using our Employee Management Application, then calls the method System.exit(0);

For this assignment, we will convert the text-based Controller2 application from the previous assignment to a GUI application. The class name should be Controller3_abcde6. Likewise, Employee2 should be renamed Employee3. The new design requirements are:

As before, the program should be implemented as a single file containing the two Java classes Controller3 and Employee3. All data members should be declared as private; all methods should be declared without any visibility modifiers. It is not necessary to provide error-checking for this application; you may safely assume that the user will only enter valid inputs. However, please carefully follow the formats given; points will be deducted for non-standard input formats.

1) Contoller3 should extend JFrame and implement the ActionListener interface. Each Controller3 object should have, in addition to the prior data members:

a) One JPanel, added directly to the Controller3 object, and containing the JPanels in 1b) and 1c)

b) One one JPanel, a set of JButtons, one for each of the functions in the previous assignment: add, delete, update employee, update field, read, and exit with appropriate labels

c) On a second JPanel:

i) a JTextField object for user input. The JTextField should be cleared (use setText("") to clear it) whenever a new input is needed

ii) a JTextArea object for output. The JTextArea should be cleared (again, use setText("")) whenever a new command is processed (i.e., a JButton is pressed). Otherwise, successive lines of text should use its append method.

2) The GUI should respond to clicked JButtons as if the user had entered the same text command in the previous assignment. For example, if the user presses the Delete JButton, the program should display a prompt asking the index to delete in the output JTextArea, which the user enters in the input JTextField, triggering the deletion process.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions