subject

(Recommended Project: Combining Composition and Inheritance) In this chapter, we created the CommissionEmployee– inheritance hierarchy to model the relationship between two types of employees and how to calculate the earnings for each. Another way to look at the problem is that CommissionEmployees and are each Employees and that each has a different CompensationModel object. A CompensationModel would provide an earnings method. Subclasses of CompensationModel would contain the details of a particular Employee’s compensation: —For Employees CompensationModel subclass would contain grossSales and commissionRate instance variables, and would define earnings to return grossSales * commissionRate. —For Employees who are paid a base salary and commission, this CompensationModel subclass would contain instance variables grossSales, commissionRate and baseSalary and would define earnings to return baseSalary + grossSales * commissionRate. Class Employee’s earnings method would simply call the composed CompensationModel’s earningsmethod and return its result. This approach is more flexible than our original hierarchy. For example, consider an Employee who gets promoted. With the approach described here, you can simply change that Employee’s CompensationModel by assigning the composed CompensationModel reference an appropriate subclass object. With the CommissionEmployee– hierarchy, you’d need to change the employee’s type by creating a new object of the appropriate class and moving data from the old object into the new one. Implement the Employee class and CompensationModel hierarchy discussed in this exercise. In addition to the firstName, lastName, socialSecurityNumber and CompensationModel instance variables, class Employee should provide: A constructor that receives three Strings and a CompensationModel to initialize the instance variables. A set method that allows the client code to change an Employee’s CompensationModel. An earnings method that calls the CompensationModel’s earnings method and returns its result. When you invoke method earnings via the superclass CompensationModel reference to a subclass object (of type or ), you might expect superclass CompensationModel’s earnings method to execute. What actually happens? The subclass object’s earnings method executes. This is called polymorphic behavior, which we explore in Chapter 10. In your test application, create two Employee objects—one with a CommissionCompensation-Model and one with a —then display each Employee’s earnings. Next, change each Employee’s CompensationModel dynamically and redisplay each Employee’s earnings. In Chapter 10 ’s exercises, we’ll examine how to implement CompensationModel as an interface rather than a class.
Java language

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:50
A.) generate scaffolding to create database for your application. develop all the entities identified in assignment #2. add any additional that may be identified later. b.) add data validation rules to the models that are appropriate for your application and data. c.) create links for each scaffold in the header section. part 2: application updates [30 points] a.) add two additional views to the "home" controller you created in assignment #1. b.) the two views should be named as “privacy" and "". c.) link the two newly created views in the footer section. hint: you would need to modify the “home" controller definition and create “privacy.html.erb" and “.html.erb" files in appropriate locations.
Answers: 3
question
Computers and Technology, 22.06.2019 03:40
Hello my name is mihai and i need your : )i have to do a python project in computer science and i’m really busy with my mocks this period of time besides this i’m not good at coding so could someone pls pls pls sort me out ? i actually beg ; ))
Answers: 1
question
Computers and Technology, 22.06.2019 14:40
For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. after converting to the postfix expression, the program should evaluate the expression from the postfix and display the result. what should you submit? write all the code in a single file and upload the .c file. compliance with rules: ucf golden rules apply towards this assignment and submission. assignment rules mentioned in syllabus, are also applied in this submission. the ta and instructor can call any students for explaining any part of the code in order to better assess your authorship and for further clarification if needed. problem: we as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). in computer's language, however, it is preferred to have the operators on the right side of the operands, ie. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix write a program that takes an "infix" expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % ( example infix expression: (7-3)/(2+2) postfix expression: 7 3 2 2 result: rubric: 1) if code does not compile in eustis server: 0. 2) checking the balance of the parenthesis: 2 points 3) incorrect postfix expression per test case: -2 points 4) correct postfix but incorrect evaluation per test case: -i points 5) handling single digit inputs: maximum 11 points 6) handling two-digit inputs: 100 percent (if pass all test cases)
Answers: 3
question
Computers and Technology, 23.06.2019 09:20
How to print: number is equal to: 1 and it is odd number number is equal to: 2 and it is even number number is equal to: 3 and it is odd number number is equal to: 4 and it is even number in the console using java using 1 if statement, 1 while loop, 1 else loop also using % to check odds and evens
Answers: 3
You know the right answer?
(Recommended Project: Combining Composition and Inheritance) In this chapter, we created the Commiss...
Questions
question
Biology, 18.12.2019 07:31
question
English, 18.12.2019 07:31
Questions on the website: 13722360