Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class PolymorphismTest 7 public static void main( String[] args assign su

ID: 3837346 • Letter: P

Question

public class PolymorphismTest 7 public static void main( String[] args assign superclass reference to superclass variable Commission Employee commissionEmployee new CommissionEmployeeC Jones 12 assign subclass reference to subclass variable 13 BasePlusCommissionEmployee basePlusCommissionEmployee 15 new Base Plus CommissionEmployeeC "Bob", Lewis 333-33-3333 5000, .04, 300 17 invoke toString on Superclass object using superclass var able System.out.printf( "%s %s:VnMnxs Vn" "Call CommissionEmployee's toString with ass reference Variable refers to a to superclass object commissionEmployee.toString O 20 21 CommissionEnployee 22 object, so that class's toString method is Fig. IO.I I Assigning superclass and subclass references to superclass and subclass called variables. (Part I of 3.) Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. invoke toString on subclass object using subclass variable 23 Call BasePluscommissionEmployee's tostring with subclass". Variable refers to a reference to subclass obiect 26 BasePlus- basePlusCommissionEmployee.toSt Commission Enployee 28 object, so that class's 29 invoke to String on subclass object using superclass variable toString method is mmission Employee commissionEmployee2 called basePluscommissionEmployee; 3I System.out.printf "is xs:An nis n' Variable refers to a Call BasePlus Commission Employee's toString with supercla BasePlus- reference to subclass object commissionEmployee2.tostringo 34 CommissionEnployee 35 end main object, so that class's 36 end class PolymorphisaTest toString method is called Call Commission Employee's toString with superclass reference to superclass object: commission employee: Sue Jones social security number: 222-22-2222 gross sales: 10000.00 commission rate: 0.06 Fig. 10 Assigning superclass and subclass references to superclass and subclass variables. (Part 2 of 3.)

Explanation / Answer

Solution:

Answer 1:

public class PieceWorker /*extends Employee*/{

private Integer wagePerPiece;
private Integer piecesProduced;

public PieceWorker(){}

public PieceWorker(/*Add Employee class variables first*/Integer wagePerPiece, Integer piecesProduced) {
super(/*Add Employee class variables here also(just variable names and not type)*/);
this.wagePerPiece = wagePerPiece;
this.piecesProduced = piecesProduced;
}

public Integer getWagePerPiece() {
return wagePerPiece;
}
public void setWagePerPiece(Integer wagePerPiece) {
this.wagePerPiece = wagePerPiece;
}
public Integer getPiecesProduced() {
return piecesProduced;
}
public void setPiecesProduced(Integer piecesProduced) {
this.piecesProduced = piecesProduced;
}

public Integer earnings(){
return this.wagePerPiece*this.piecesProduced;
}

}

TESTER PROGRAM

import java.util.ArrayList;
import java.util.List;

public class Tester {

/*
* Since Employee class implementation
* is not provided so the tester is
* written in accordance to PieceWorker;
* necessary replacements need to be made
* for Employee class objects
*/
public static void pieceWorkerTester(){
List<PieceWorker> testList = new ArrayList<PieceWorker>();
for(int i=1; i<=10; i++){
int j=i+4;
PieceWorker obj = new PieceWorker(i, j);
testList.add(obj);
}
int counter = 1;
for(PieceWorker element: testList){
System.out.println("Worker No "+String.valueOf(counter++)+": "+element.earnings());
  
}
}
  
public static void main(String[] args) {
pieceWorkerTester();
}
}

Answer 2:

public interface Person {

void setFirstName(String firstName);
void setLastName(String lastName);
String getFirstName();
String getLastName();
void eat();
void think();
void sleep();
}

/*Implementation details not mentioned*/

public abstract class Philosopher implements Person{

@Override
public void setFirstName(String firstName) {
// TODO Provide your implementation
  
}

@Override
public void setLastName(String lastName) {
// TODO Provide your implementation
  
}

@Override
public String getFirstName() {
// TODO Provide your implementation
return null;
}

@Override
public String getLastName() {
// TODO Provide your implementation
return null;
}

@Override
public void sleep() {
// TODO Provide your implementation
  
}

}

Answer 3:

Please provide some sample file data. The implementation needs a POJO class to store the data from both files and sort and then write the sorted data to the files