Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework is asking us to adapt Question: Polymorphism - Interface to JavaFX . QUESTION: POLYMORPHISM - INTERFACE ENDS HERE. NOW WE'RE HEADING BACK TO HOMEWORK.

Homework is asking us to adapt "Question: Polymorphism - Interface" to JavaFX.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

QUESTION: POLYMORPHISM - INTERFACE ENDS HERE. NOW WE'RE HEADING BACK TO HOMEWORK.

image text in transcribedimage text in transcribed

Homework Problem Description: CEO of Factory X make a request to your software company about design a program with user interface. The program should calculate Factory X's payment amount which will be made for all type of employees. Create Payable (interface), Employee, SalariedEmployee, HourlyEmployee, CommissionEmployee, BasePlusCommissionEmployee, and Test (main) class according to requirements given in the question below. NOTE: Do not use invoice class from the question below, it is not needed. You may use other classes. If necessary, make some changes to provide true encapsulation (design all data fields as private and reach them just using get/set methods) and inheritance practice in your implementation. Question: Polymorphism-Interface NOTE: Use true encapsulation (design all data fields as private and reach them just using get/set methods) and inheritance practice in your implementation. Your project have to consist of 8 classes: Payable, Invoice, Employee, SalariedEmployee, HourlyEmployee, CommisionEmployee, BasePlusCommisionEmployee, PayableInterfaceTest NOTE: Do not use earnings 0 method for this homework instead, getPaymentAmount 0 of Payable interface will be implemented. NOTE: Do not take input from user!| + CEO of Factory X make a request to your software company about design a program that calculates Factory X's payment amount which will be made for employees and invoices. Create Invoice, Payable (interface), Employee, SalariedEmployee, HourlyEmployee, CommissionEmployee, BasePlusCommissionEmployee, and Test (main) class according to requirements given below. Hierarchy between classes: - Invoice implements Payable public class Invoice implements Payable - Employee implements Payable - Employee is abstract superclass. Each employee has a first name, a last name and a social security number. There is no getPaymentAmount () method in Employee class public abstract class Employee implements Payable - Salaried Employee, Hourly Employee, Commission Employee is an Employee. - BasePlusCommissionEmployee is a Commission Employee. - Each class has different behavior in getPaymentAmount () and toString () methods. NOTE: There is no getPaymentAmount () method in Employee class. Factory X's payment amount which will be made for its employees on a weekly basis. The employees are of four types: - Salaried employees are paid a fixed weekly salary regardless of the number of hours worked - Hourly employees are paid by the hour and receive overtime pay (i.e., 1.5 times their hourly salary rate) for all hours worked in excess of 40 hours - Commission employees are paid a percentage of their sales - Base plus commission employees receive a base salary plus a percentage of their sales. Factory X's payment amount which will be made for invoice: - Invoice 's payment amount is calculated by multiplying quantity and price per item. Payable - Design an interface named Payable with a method: double getPaymentAmount () . public interface Payable \{ double getPaymentAmount (); \} Invoice public class Invoice implements Payable - Create a class named Invoice contains billing information for only one kind of part: - implements Payable - private partNumber, partDescription, quantity and pricePerItem data fields - 4 argument Constructor: Validation: quantitiy must be >=0, price must be >0 Make necessary assignments. - get/set methods for partNumber, partDescription, quantity and pricePerItem Apply validation in set methods. - toString 0 method returns string representation of an object. - Implement Payable's getPaymentAmount 0 that returns multiplication of quantity and pricePerItem. Employee - Employee is abstract superclass. - implements Payable - private firstName, lastName and social security number (SSN) data fields. - 3 argument Constructor - get/set methods for firstName, lastName and social security number (SSN) - toString 0 method returns string representation of an object. - getPaymentAmount 0 method of Payable interface should not be coded in Employee class. The method content changes employee to employee so, it should be coded in all subclasses of Employee and Invoice - Employee class must be declared Abstract to avoid compilation error because getPaymentAmount 0 is not implemented in the class. SalariedEmployee - Subclass of Employee - private weeklySalary data field -4 argument Constructor: Use super keyword when invoking superclass constructor, Validation: weeklySalary must be >=0 Make necessary assignments. - get/set methods for weeklySalary Apply validation in set method. I - Implement getPaymentAmount ( ) and override toString 0 methods according to table above. Use super if necessary HourlyEmployee - Subclass of Employee - private wage, hours data fields - 5 argument Constructor: Use super keyword when invoking superclass constructor, Validation: wage must be >=0, hours must be >=0 and =0, commissionRate >0 and =0 Make necessary assignments. - get/set methods for baseSalary Apply validation in set methods. - Implement getPaymentAmount() and override toString 0 methods according to table above. Use super if necessary Test (Main class) You may use your own preferred data field values while creating objects. Create Payable type array which contains 6 elements. Payable payableobjects [] = new Payable [ 6 ]; itialize array with references of 2 Invoice object, a reference of SalariedEmployee, HourlyEmployee, CommissionEmployee, BasePlusCommissionEmployee repectively. payableobjects [0] = new Invoice (.); payableobjects [1 1 = new Invoice (.); payableobjects [2 ] = new SalariedEmployee (.); payableobjects [3] = new HourlyEmployee (.); payableobjects [4 ] = new Commissionemployee (.); payableobjects [5] = new BaseplusCommissionEmployee (...); Polymorphic Usage of Interface: - For each element in the array; - Print the element - Decide if element is a BasePlusCommissionEmployee or not if ( payableobjects[i] instanceof BaserluscommissionEmployee) If so, increase baseSalary of employee by adding %10 of current baseSalary and print new baseSalary - Print getPaymentAmount() - Print the class name of each object in the array using default superclass Object's related method. payableobjects [j].getClass () . getName () EMPLOYEE SALARY CALCULATOR Choose Employee Type Salaried Employee First Name Hourly Employee Commission Employee Last Name Base Plus Commission Employee 5SN None Search/Update SSN Weekly Salary SALARY VALUE Wage Hours EMPLOYEE SALARY CALCULATOR Choose Employee Type Salaried Employee First Name John Gross Sales Last Name Smith Commission Rate 5SN Base Salary Search/Update SSN Weekly Salary SALARY Wage Hours Add \begin{tabular}{|l||l|l} Search by SSN & Update by SSN & Clean textfields \end{tabular} 1- Your program should store, add, update and search salary information of all type employees as shown in figures above. Use random access file(.dat) or text file (.txt) for reading and writing, an employee information. - Program should perform Add, Search by SSN, Update by SSN CleanTextFields operations. - SSN text field should be "read only" and SSN should be set in the code for each record, do not take from user. - When program starts, read all records from random access file or text file and save each record in Employee []. (Employee array) - Update both Employee [] and random access file or text file when add and update operations happen. - Add: Select employee type from dropdown list. According to your selection, related text fields are enabled, unrelated text fields are disabled (Search/Update SSN text field always enabled). Enter employee information into enabled text fields, then press "add button". Your employee record will be written into file. Also add that record into your Employee[] - Search by SSN: Enter SSN of employee whose information you want to reach, into "Search/Update SSN text field". Press "Search by SSN button". Then all information related to the employee will be displayed, such as employee type, first name, last name, SSN, salary etc.. - Update by SSN: Enter SSN of employee whose information you want to update, into "Search/Update SSN text field". Enter other fields you want to update, then press "Update by SSN button". Employee record which is placed in file should be updated. Also, Employee[] should be updated. - Clean TextFields: Cleans all text fields

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_2

Step: 3

blur-text-image_3

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

4. In Exercise 3, are the random variables X and Y independent?

Answered: 1 week ago

Question

How do you try to manipulate your unique smell?

Answered: 1 week ago