Details of this Paper

Cloneableand Comparable

Description

solution


Question

Part I: Short answer questions (75 points);1. You can always add a compareTo() method to a class without making it implementthe Comparable interface, so why do you need the Comparable interface? What are theadvantages of making your classes implement the Comparable interface when you want them toprovide a compareTo() method?;2. What are your suggestion of features you think IDE should have that will improve userexperience, coding easiness, and program quality. Suggestions can be both java specificor in general for program development.;3. To write a Java FX application (think a very simple one, like the ones youdid), what are the essential key things you need in your code?;4. In both Java and Java FX, there are classes for graphics, such as font, color,and shapes. Are they the same? What are the differences?;5. Why do we say that ?mobile strategy? is more than developing a version ofyour website for smaller screen?;Part II: Programming task (25 points);First International Resource Management, Inc. (aka. FIRM) asks you to develop programs to solve the following problem.;FIRM pays its employees on a weekly basis. FIRM has four types of employees: salaried employees, who are paid a fixed weekly salary regardless of the number of hours worked, hourly employees, who are paid by the hour and receive overtime pay, commission employees, who are paid a percentage of their sales, and salaried-commission employees, who receive a base salary plus a percentage of their sales. FIRM wants to implement a java application that performs its payroll calculations polymorphically. Of course each employ belongs to a department.;Based on the description of the problem and several discussions with the client, a class diagram is agreed upon and the class hierarchy is shown in the diagram. At first, the management wants to implement three employee types: HourlyEmployee, SalariedEmployee, and CommissionEmployee.;Development of Classes and an Interface;Employee: abstract super class;Attributes;? Employee name: String;Methods;? Constructor: with one parameter of employee name;? Get and set methods for the attribute;? earnings(): Abstract method that will return a double value;SalariedEmployee: subclassof Employee;Additional Attribute;? weeklySalary: double;Methods;? Constructor: with two parameters of employee name and weekly salary;? Constructor: with one parameter of employee name, and default salary is $800.;? Get and set methods for weeklySalary;? earnings(): return weekly salary;HourlyEmployee: subclass of Employee;Addition Attributes;? wage: double;? hours: double;Methods;? Constructor: with three parameters of employee name, wage, and hours;? Constructor: with two parameters of employee name and hours, default wage is $8.;? Get and set methods for wage and hours;? earnings(): if the employee worked overtime (hours>40), the overtime portion is paid half timemore than regular wage.;CommissionEmployee: subclass of Employee;Additional Attribute;? grossSales: double;? commissionRate: double;Methods;? Constructor: with three parameters of employee name, gross sales, and commission rate.;? Constructor: with two parameters of employee name and gross sales, and default rate is 0.05.;? Get and set for grossSales and commissionRate;? earnings(): commission is calculated as gross sales times commission rate.;BasePlusCommissionEmployee: subclass of CommissionEmployee.;All the classes also need to have a method to print out pay check, which will show company name, basic information of the employee, and earnings of the current week. An interface class Company is used for the purpose and all the employee types will implement this interface.;Company: interface;Attribute;? Company name: First International Resource Management, Inc.;Methods;? toString(): return a string including the key information about the employee;Programming Tasks;1. Please revise Employee class that it also implements Cloneable and Comparable. Two persons are the same if they have the same name. The compareTo() method should return 0 if the two names are the same. Return -1 (or a negative number) if this employee name precedes the argument string. Otherwise return a +1 (or a positive number). Clone() will create an object with the same information.;2. Use the class OrderArrayList to keep track of the employees. Maximum number is 500. When printing the list, sort data alphabetically. So, when adding employees into the list, it is sorted by employee name. You may need to examine the methods in OrderArrayList to make sure items are added in alphabetically. In the program, you can use fake data (like the ones in the following table) to populate the list and print the list out to see whether it works.;A sample run may look like this;? ?? ----jGRASP exec: java LastAssignment;???;??? First International Resource Management, Inc.;??? Salary-based employee;??? Name: Avery Tolar;??? Earnings: $1,000.00;??? First International Resource Management, Inc.;??? Commission employee;??? Name: Tammy Hemphill;??? Earnings: $725.00;??? First International Resource Management, Inc.;??? Hourly employee;??? Name: Wayne Tarrance;??? Earnings: $500.00;???;???;??? ----jGRASP: operation complete.;Other requirements;? JAVA programs;o Use comments in your java program. It is also a good idea to use comments at the beginning of your code indicating programmer and project information.;o Practice good programming habits.

 

Paper#70954 | Written in 18-Jul-2015

Price : $32
SiteLock