Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Employee.Java Somewhat simplified from a real world usge, the class named Employee has three instance variables, a first name and a last name, each of

Employee.Java

Somewhat simplified from a real world usge, the class named Employee has three instance variables, a first name and a last name, each of type Employee, and a monthly salary. The constructor for the class initializes (that is, gives initial values to) these instance variables. The class also has setters (methods that begin with the word set...) that enables the values of the instance variables to be changed. There are conditions (validations) to be met for each of the three valuesif the conditions are not met, a message is to be printed on the standard output file. In addition, there is a method for displaying (on the standard output file) the current values held by an instance of the class, as well as a toString method (useful for debugging).

The UML below defines the needed field variables (three of them) and their types, the constructor, and the needed methods.

Define a constructor for the class. The details of the constructor interface are shown in the UML specification below. The values supplied as arguments for the constructor are used to initialize the corresponding fields (see next item).

Create the three instance variables as requested. The names for these instance variables are specified in the UML below.

Create the getters and setters for each of the properties first, last and monthlySalary, that use these instance variables. The property yearlySalary has only a getter, but no setter. Note the names of the properties are not the same as the identifiers of the instance variables.

Create a method in the Employee class, named displayValues, that writes to the standard output file the employee's complete name, monthly salary, and annual salary. The test program will use calls to that method to display Employee object values. See examples of this output in the output sample below.

Override the inherited toString method.

The following UML provides a description of the API for the class. In this description, indicates a private member, and + indicates a public constructor or member:

Employee

- firstNameFieldValue: String - lastNameFieldValue: String - salaryFieldValue: double

+ Employee(firstName: String, lastName: String, initialSalary: double) + displayValues() + getFirst(): String + setFirst(firstName: String) + getMonthlySalary(): double + getYearlySalary(): double + setMonthlySalary(salary: double) + getLast(): String + setLast(lastName: String) + toString(): String

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

Question

Draft a proposal for a risk assessment exercise.

Answered: 1 week ago