Error Message: Cannot find symbol constructor

[color=Blue]This is the derived file below. When I run it I get an error message of cannot find symbol constructor Salaried Employee. The assignment requires us to create a derived file from the class Salaried Employee which is derived from the class Employee. We are to create 3 instance variables of type string for Title, Responsibility and Supervisor. Also suitable constructors, accessor and mutator methods. A method for reading in admin. data from the keyboard. The Salaried Employee code is also listed below this.. Help would greatly be appreciated to find this error[/color].


import java.io.*;
import java.util.*;

public class Administrator extends SalariedEmployee
{
//instance variables...
private String AdminTitle;
private String AdminResp;
private String AdminSupv;


//Constructor Method
public Administrator()

{
super( );
AdminTitle = null;
AdminResp = null;
AdminSupv = null;

}//end of constructor

//constructor with arguments
public Administrator(String theName, double theSalary, Date theDate, String theTitle,
String theResp, String theSupv)

{
super(theName, theSalary, theDate);


if (theTitle != null)
AdminTitle = theTitle;

if (theResp != null)
AdminResp = theResp;

if (theSupv != null)
AdminSupv = theSupv;
else
{
System.out.println("Fatal Error: Must include all employee information!");
System.exit(0);
}
}

public Administrator(Administrator originalObject)
{
super(originalObject);
AdminTitle = originalObject.AdminTitle;
AdminResp = originalObject.AdminResp;
AdminSupv = originalObject.AdminSupv;
//theSalary = originalObject.theSalary;
}


public String getTitle( )
{
return AdminTitle;
}

public String getResp( )
{
return AdminResp;
}

public String getSupv( )
{
return AdminSupv;
}

// public double getSalary()
// {
// return theSalary;
// }


// Precondition: Admin info not null.
public void setAdminTitle(String newAdminTitle)
{
if (newAdminTitle !=null)
AdminTitle = newAdminTitle;
else
{
System.out.println("Title must have a value.");
System.exit(0);
}
}

public void setAdminResp(String newAdminResp)
{
if (newAdminResp !=null)
AdminResp = newAdminResp;
else
{
System.out.println("Responsibility must have a value.");
System.exit(0);
}
}

public void setAdminSupv(String newAdminSupv)
{
if (newAdminSupv !=null)
AdminSupv= newAdminSupv;
else
{
System.out.println("Supervisor must have a value.");
System.exit(0);
}
}

public String toString()
{
return (getName() + " " + getHireDate().toString()+"
$" +getSalary() + " per year" + " "
+ AdminTitle +" is" + " their responsibilities include "+
AdminResp + " they report to " + AdminSupv);
}


/** public boolean equals(Administrator other)
{
return (getName( ).equals(other.getName( ))
&& getHireDate( ).equals(other.getHireDate( ))
&& salary == other.salary);
} */



//Method to Allow User to Input Data

public void inputAdminData()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the Employees Name");
String theName = keyboard.next();
System.out.println("Enter the Emploees Hire Date");
String theDate = keyboard.next();
System.out.println("Enter the Employees Salary");
String theSalary = keyboard.next();
System.out.println ("Enter the Employees Title");
String AdminTitle = keyboard.next();
System.out.println ("Enter the Employees Area of Responsibility");
String AdminResp = keyboard.next();
System.out.println ("Enter the Employees Supervisor");
String AdminSupv = keyboard.next();

}

}
-----------------------------------------------------------------------
Here is the Salary class...



/**
Class Invariant: All objects have a name string, hire date,
and nonnegative salary. A name string of "No name" indicates
no real name specified yet. A hire date of Jan 1, 1000 indicates
no real hire date specified yet.
*/
public class SalariedEmployee extends Employee
{
private double salary; //annual

public SalariedEmployee( )
{
super( );
salary = 0;
}

/**
Precondition: Neither theName nor theDate are null;
theSalary is nonnegative.
*/
public SalariedEmployee(String theName, Date theDate, double theSalary)
{
super(theName, theDate);
if (theSalary >= 0)
salary = theSalary;
else
{
System.out.println("Fatal Error: Negative salary.");
System.exit(0);
}
}

public SalariedEmployee(SalariedEmployee originalObject )
{
super(originalObject);
salary = originalObject.salary;
}

public double getSalary( )
{
return salary;
}

/**
Returns the pay for the month.
*/
public double getPay( )
{
return salary/12;
}

/**
Precondition: newSalary is nonnegative.
*/
public void setSalary(double newSalary)
{
if (newSalary >= 0)
salary = newSalary;
else
{
System.out.println("Fatal Error: Negative salary.");
System.exit(0);
}
}

public String toString( )
{
return (getName( ) + " " + getHireDate( ).toString( )
+ "
$" + salary + " per year");
}

public boolean equals(SalariedEmployee other)
{
return (getName( ).equals(other.getName( ))
&& getHireDate( ).equals(other.getHireDate( ))
&& salary == other.salary);
}
}




Comments

  • When you call super, you use:

    super(theName, theSalary, theDate);

    however, your constructor is set up as:

    public SalariedEmployee(String theName, Date theDate, double theSalary)

    thus, you just need to switch theSalary and theDate, like so:

    super(theName, theDate, theSalary);
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion