Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: error cannot find symbol-constructor Person(java.lang.String,java.lang.String,Date)

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 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:

    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:


    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.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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.

    super(other.name, other.gender.charAt(0), other.dateOfBirth);

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: error cannot find symbol-constructor Person(java.lang.String,java.lang.String,Dat

    Thank you. That worked.

    Thank you again for your help.


Similar Threads

  1. Java.lang.reflect.invocationTargetException
    By varun in forum Exceptions
    Replies: 5
    Last Post: November 3rd, 2009, 10:40 AM
  2. Getting "AWT-EventQueue-0" java.lang.NullPointerException error
    By tryingtoJava in forum AWT / Java Swing
    Replies: 9
    Last Post: September 21st, 2009, 10:46 PM
  3. [SOLVED] find the position of the field separator in the String---need help ASAP
    By rajesh.mv in forum Java Theory & Questions
    Replies: 6
    Last Post: August 17th, 2009, 10:33 AM
  4. How to reverse a String using java.lang.StringBuilder
    By JavaPF in forum Java SE API Tutorials
    Replies: 0
    Last Post: July 22nd, 2009, 09:42 AM
  5. [SOLVED] Facing java error "cannot be applied to (java.lang.String)"
    By tazjaime in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 23rd, 2009, 10:19 AM