The three java files (source code) pasted below associated with this question. Any help will be greatly appreciated!! QUESTION (using Eclipse and default Junit package that came with it): Create a Junit 4 test case for the Hourly class. Your test should use these methods from class org.junit.Assert: assertEquals to test the getJob() method assertEquals to test the getPayRate() method assertTrue to test the hours attribute Admin.java package ch44extra;   import java.time.LocalDate;   public class Admin extends Person { private String dept; private String office; private double salary; //private double budget;removed to simplify class   public Admin(String name, LocalDate date, int id, String dept, String office, double salary) { super(name, date, id); this.dept = dept; this.office = office; this.salary = salary; }   public Admin() { super(); // TODO Auto-generated constructor stub }   public String getDept() { return dept; }   public void setDept(String dept) { this.dept = dept; }   public String getOffice() { return office; }   public void setOffice(String office) { this.office = office; }   public double getSalary() { return salary; }   public void setSalary(double salary) { this.salary = salary; }   @Override public void pay() { double pay = salary / 12; System.out.printf("Annual Salary pays $%,.2f monthly\n",pay); }   @Override public String toString() { Strings = super.toString(); s += "\nAdmin dept=" + dept + ", office=" + office + ", salary=" + String.format("$%,.0f",salary); returns; } } Hourly.java package ch44extra;   import java.time.LocalDate;   public class Hourly extends Person { private double payRate; private double hours; private String job;   public Hourly(String name, LocalDate date, int id, double payRate, double hours, String job) { super(name, date, id); this.payRate = payRate; this.hours = hours; this.job = job; }   public double getPayRate() { return payRate; }   public void setPayRate(double payRate) { this.payRate = payRate; }   public double getHours() { return hours; }   public void setHours(double hours) { this.hours = hours; }   public String getJob() { return job; }   public void setJob(String job) { this.job = job; }   @Override// implements abstract method pay inherited from Person public void pay() { double pay = payRate * hours; System.out.printf("%.2f hours @ $%.2f = $%.2f weekly\n",hours,payRate,pay); }   @Override public String toString() { return super.toString() + "\n" + "payRate=" + String.format("$%.2f",payRate) + ", hours=" + hours + ", job=" + job; } } Person.java package ch44extra;   import java.time.LocalDate;   // abstract because it contains the abstract method pay public abstract class Person implements Comparable { protected String name; protected LocalDate date; protected int id; // deleted salary field, added id   public Person(String name, LocalDate date, int id) { super(); this.name = name; this.date = date; this.id = id; }   public Person() { }   // getters not needed since attributes are now protected   // abstract method, so Person class must be abstract public abstract void pay();  // no braces, no body   @Override public int compareTo(Person arg0) { return date.compareTo(arg0.date); }   @Override public String toString() { return "Name=" + name + ", hired=" + date + ", id number=" + id ; }   }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The three java files (source code) pasted below associated with this question.

Any help will be greatly appreciated!!

QUESTION (using Eclipse and default Junit package that came with it):

Create a Junit 4 test case for the Hourly class. Your test should use these methods from class org.junit.Assert:

  • assertEquals to test the getJob() method
  • assertEquals to test the getPayRate() method
  • assertTrue to test the hours attribute

Admin.java

package ch44extra;

 

import java.time.LocalDate;

 

public class Admin extends Person {

private String dept;

private String office;

private double salary;

//private double budget;removed to simplify class

 

public Admin(String name, LocalDate date, int id, String dept, String office, double salary) {

super(name, date, id);

this.dept = dept;

this.office = office;

this.salary = salary;

}

 

public Admin() {

super();

// TODO Auto-generated constructor stub

}

 

public String getDept() {

return dept;

}

 

public void setDept(String dept) {

this.dept = dept;

}

 

public String getOffice() {

return office;

}

 

public void setOffice(String office) {

this.office = office;

}

 

public double getSalary() {

return salary;

}

 

public void setSalary(double salary) {

this.salary = salary;

}

 

@Override

public void pay() {

double pay = salary / 12;

System.out.printf("Annual Salary pays $%,.2f monthly\n",pay);

}

 

@Override

public String toString() {

Strings = super.toString();

s += "\nAdmin dept=" + dept + ", office=" + office + ", salary=" + String.format("$%,.0f",salary);

returns;

}

}

Hourly.java

package ch44extra;

 

import java.time.LocalDate;

 

public class Hourly extends Person {

private double payRate;

private double hours;

private String job;

 

public Hourly(String name, LocalDate date, int id, double payRate, double hours, String job) {

super(name, date, id);

this.payRate = payRate;

this.hours = hours;

this.job = job;

}

 

public double getPayRate() {

return payRate;

}

 

public void setPayRate(double payRate) {

this.payRate = payRate;

}

 

public double getHours() {

return hours;

}

 

public void setHours(double hours) {

this.hours = hours;

}

 

public String getJob() {

return job;

}

 

public void setJob(String job) {

this.job = job;

}

 

@Override// implements abstract method pay inherited from Person

public void pay() {

double pay = payRate * hours;

System.out.printf("%.2f hours @ $%.2f = $%.2f weekly\n",hours,payRate,pay);

}

 

@Override

public String toString() {

return super.toString() + "\n" + "payRate=" + String.format("$%.2f",payRate) + ", hours=" + hours + ", job=" + job;

}

}

Person.java

package ch44extra;

 

import java.time.LocalDate;

 

// abstract because it contains the abstract method pay

public abstract class Person implements Comparable<Person> {

protected String name;

protected LocalDate date;

protected int id; // deleted salary field, added id

 

public Person(String name, LocalDate date, int id) {

super();

this.name = name;

this.date = date;

this.id = id;

}

 

public Person() {

}

 

// getters not needed since attributes are now protected

 

// abstract method, so Person class must be abstract

public abstract void pay();  // no braces, no body

 

@Override

public int compareTo(Person arg0) {

return date.compareTo(arg0.date);

}

 

@Override

public String toString() {

return "Name=" + name + ", hired=" + date + ", id number=" + id ;

}

 

}

 

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education