Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Employee that should include four pieces of information as instance variablesa firstName (type String ), a lastName (type String ), a

Create a class called Employee that should include four pieces of information as instance variablesa firstName (type String), a lastName (type String), a mobileNumber (type String) and a salary (type int).

1) Your class (Employee) should have a full argumentconstructor that initializes the four instance variables.
2) Provide a set and a get method for each instance variable. The validation for each attribute should be like below:
a. mobileNumber should be started from 05 and the length will be limited to 10 digits.
b. salary should be greater than zero.
3) In addition, provide a method named getYearlySalary()that calculates the yearly salary (i.e., multiplies the salaryby 12), then returns the amount as a double value.
4) The toString() print the following information

Employee Name: FirstName LastName

Mobile No. 0512345678

Employee Salary: 2000

5) Override the equals() method to return the true if the current Employee object has the same firstName and lastNamefields as the Employee object referenced by the input argument and false otherwise.

Derived Class Information

1) Create another class called SalesEmployee which inherits all the properties of Employee Class. The SalesEmployeeshould include specific attributes- a sales (type int) and a commissionRate (type double).
2) SalesEmployee Class should have a full argumentconstructor that initializes the SIX instance variables(Base Class (4) and Derived Class (2)). Call constructor of base class, i.e., Employee class from derived class (SalesEmployee) constructor as below:
a. Super (fname, lname, mobile, salary)
3) Provide a set and a get method for each specific attribute of SalesEmployee class.
4) Override the getYearlySalary() method in SalesEmployee class to calculate the salary as below:

return ((super.salary + (sales * commissionRate)) * 12);

6) The toString() print the following information

Employee Name: FirstName LastName

Mobile No. 0512345678

Sales Employee Salary: 22000

3. Override the equals() method to return the true if the current SalesEmployee object has the firstName, lastName, and salesfields as the SalesEmployee object referenced by the input argument and false otherwise.

Important Note 3: Make sure to call the equals() method of the SalesEmployee class.

InheritanceTest Class Information

1) Write a test app named InheritanceTest that demonstrates class Employee and SalesEmployee classes capabilities.
2) Create an object (i.e., empObj) of Employee class and print all the information in the defined toString() method format.
3) Create an object (i.e., SalesEmpObj) of SalaesEmployeeclass and print all the information in the defined toString()method format.

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

Recommended Textbook for

Database Systems For Advanced Applications 18th International Conference Dasfaa 2013 Wuhan China April 22 25 2013 Proceedings Part 2 Lncs 7826

Authors: Weiyi Meng ,Ling Feng ,Stephane Bressan ,Werner Winiwarter ,Wei Song

2013th Edition

3642374492, 978-3642374494

More Books

Students also viewed these Databases questions