Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please create an array and a array list of employee implemented in the code you have written. Sort the array/list by their ID's. Basically, i

Please create an array and a array list of employee implemented in the code you have written. Sort the array/list by their ID's.

Basically, i am unsure of what I really have to do and where I would have to implement the array and array list. If you could please help me out I would really appreciate it. The following is the program that I have written.

Employee.java

public abstract class Employee

{

private int ID;

private String name;

Employee(int ID, String name)

{

this.ID = ID;

this.name = name;

}

public String getName()

{ return name; }

public int getID()

{ return ID; }

public void setName(String newName)

{ name = newName; }

public void setID(int newID)

{ ID = newID; }

abstract double getSalary();

public String toString()

{ return "ID: " + ID + "Name: " + name ; }

}

FullTimeEmployee.java

public class FullTimeEmployee extends Employee

{

private double salary;

FullTimeEmployee(int ID, String name, double salary)

{

super(ID, name);

this.salary = salary;

}

public double getSalary()

{

return salary;

}

public void setSalary(double newSalary)

{

this.salary = newSalary;

}

public String toString()

{ return super.toString() + " Salary: " + salary ; }

}

PartTimeEmployee.java

public class PartTimeEmployee extends Employee {

private double hourlyWage;

private double hours;

PartTimeEmployee(int ID, String name, double hourlyWage, double hours)

{

super(ID, name);

this.hourlyWage = hourlyWage;

this.hours = hours;

}

double getSalary()

{

return (hourlyWage * hours) ;

}

void setSalary(double newHourlyWage, double newHours)

{

hourlyWage = newHourlyWage;

hours = newHours;

}

public String toString()

{ return super.toString() + " Hourly Wage: " + hourlyWage ; }

}

TestEmployee.java

public abstract class TestEmployee extends Employee {

TestEmployee(int ID, String name) {

super(ID, name);

}

public static void main(String args[])

{

FullTimeEmployee ft = new FullTimeEmployee(1001,"Sam",5000);

PartTimeEmployee pt = new PartTimeEmployee(5001,"Mary",10,60);

System.out.println(ft);

System.out.println(pt);

}

}

The Output is:

ID: 1001Name: Sam Salary: 5000.0

ID: 5001Name: Mary Hourly Wage: 10.0

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

(1 point) Calculate 3 sin x cos x dx.

Answered: 1 week ago