title: Creating a Tester Class for Java
body: <p>I need to create a tester class for my code, but I have no idea on how to do this, can someone help me? I've tried compiling this but I've got these messages:</p>
  
  <p>2 errors found:</p>
  
  <p><code>Error: The constructor PayCalculator() is undefined</code></p>
  
  <p><code>Error: The method printData() is undefined for the type PayCalculatorTester</code></p>
  
  <p>My Code:</p>
  
  <pre><code> {
      PayCalculator p1 = new PayCalculator();
      p1.setHourlyRate(8.25);
      p1.setHoursWorked(45);    
      printData();
    }
  </code></pre>
  
  <p>PayCalculator Class</p>
  
  <pre><code>public class PayCalculator
  
  {
    private double hourlyRate;
    private double hoursWorked;
  
    /**
     * Two parameter constructor
     * Add hourlyRate and hoursWorked
     * @param the hourly rate
     * @param the hours worked
     */
    public PayCalculator(double aHourlyRate, double aHoursWorked)
    {
      hourlyRate = aHourlyRate;
      hoursWorked = aHoursWorked;
    }
  
    /**
     * sets the hourly rate
     * @return hourlyRate
     */ 
    public void setHourlyRate(double aHourlyRate)
    {
      hourlyRate = aHourlyRate;
    }
  
    /**
     * gets the hourly rate
     * @param hourlyRate
     */
    public double getHourlyRate()
    {
      return hourlyRate;
    }
  
    /**
     * sets the hours worked
     * @return hoursWorked
     */ 
    public void setHoursWorked(double aHoursWorked)
    {
      hoursWorked = aHoursWorked;
    }
  
    /**
     * gets the hours worked
     * @param hours worked
     */
    public double getHoursWorked()
    {
      return hoursWorked;
    }
  
  
  
    public boolean workedOvertime()
    {
      if (hoursWorked &gt; 40)
      {
        return true;
      }
      else 
      {
        return false;
      }
    }
  
    public double numHoursOvertime()
    {
      if (hoursWorked &gt; 40)
      {
        return hoursWorked - 40;
      }
      else 
      {
        return 0;
      }
    }
  
    public double calculateGrossPay()
    {
      if (hourlyRate  &lt;= 10.25)
      {
        if (hourlyRate &lt;= 40)
          return hourlyRate * hoursWorked;
      }
      else 
      {  
        double grossPay = ((40 * hourlyRate) + ((hourlyRate * 2) * hoursWorked - 40));
        return grossPay;
      }
  
      if (hoursWorked &lt;= 60)
      {
        return hourlyRate * hoursWorked;
      }
      else
      {
        return 60 * hourlyRate;
      }
    }
  
    public double determineTaxRate(double grossPay)
    {
      if (grossPay &gt;= 800)
      {
        double tax = 0;
        tax = grossPay * 0.37;
        return tax;
      }
      else if ( grossPay &gt;= 400)
      {
        double tax = 0;
        tax = grossPay * 0.22;
        return tax;
      }
      else
      {
        double tax = 0;
        tax = grossPay * 0.12;
        return tax;
      }
    }
  
    public double calculateNetPay(double grossPay, double tax)
    {
      double calculateNetPay = grossPay - tax;
      return calculateNetPay;
    }
  
    public void printData(double grossPay, double tax)
    {
      System.out.println("Hours Worked: " + hoursWorked);
      System.out.println("Hourly rate: " + hourlyRate);
      System.out.println("Number of hours of overtime worked: " + numHoursOvertime());
      System.out.println("Worked overtime? " + workedOvertime());
      System.out.println("Gross pay: " + calculateGrossPay());
      System.out.println("Tax Rate: " + determineTaxRate(grossPay));
      System.out.println("Net Pay: " + calculateNetPay(grossPay, tax));
    }
  
  }
  </code></pre>