error cannot find symbol-constructor Person(java.lang.String,java.lang.String,Date)
I have the following error message:
cannot find symbol-constructor Person(java.lang.String,java.lang.String,Date)
I have this message in realtion to the following clone constructor:
Code :
public class Employee extends Person
{
//instance variables
protected int id;
protected Date start;
protected float salary;
//start constructors
public Employee()
{
super();
id=0;
salary=0;
start=new Date(); //set the date to the current date
}
public Employee(String nme, char sex, Date dob, int number, Date start)
{
super (nme, sex, dob);
id=number;
start= new Date(start);
salary=0;
}
//clone constructor: produces a clone of another object of the same type.
public Employee (Employee other)
{
[COLOR="red"] super(other.name, other.gender, other.dateOfBirth);[/COLOR]
salary=other.salary;
id=other.id;
start=new Date(other.start);
}
I think I have this message,because in class person gender is a char.
Below is my class person constructor coding:
Code :
public class Person
{
// instance variables
protected String name;
protected String gender;
protected Date dateOfBirth;
protected String address;
protected String natInsceNo;
protected String phoneNo;
private static int counter=0;
// start of constructor
public Person()
{
name= " ";
gender=" ";
dateOfBirth = new Date (00,00,00);
address= " ";
natInsceNo=" ";
phoneNo=" ";
counter++;
}
public Person (String nme, char sex, Date dob)
{
name=nme;
gender=Character.toString(sex);
dateOfBirth=dob;
phoneNo=" ";
if(address !=null){
System.out.println(address);
}
else{
System.out.println("You must enter your address");
}
if(natInsceNo !=null){
System.out.println(natInsceNo);
}
else
{
System.out.println("You must enter your National Insurance Number");
}
counter++;
}
How can i resolve this? I cannot change the variable types in class person because the specification has asked for the gender to be declared as string then converted to char. I need help modifying the clone constructor in class employee.
Please can someone advise me how to correct this.
Re: error cannot find symbol-constructor Person(java.lang.String,java.lang.String,Dat
I'm assuming that the string gender is a 1-letter string that's either "m" or "f" (or something like that). In this case, use the charAt() method.
Code :
super(other.name, other.gender.charAt(0), other.dateOfBirth);
Re: error cannot find symbol-constructor Person(java.lang.String,java.lang.String,Dat
Thank you. That worked.
Thank you again for your help.
=D>