Results 1 to 2 of 2
  1. #1
    collwill is offline Member
    Join Date
    Mar 2011
    Posts
    28
    Rep Power
    0

    Post Constructor Error

    Working on inheritance & Polymorphism. I have an Employee class which has a private MyDate dateHired variable. MyDate class extends to the "Employee class" which has methods which used in the Employee class. When I compile the MyDate class is getting the following errors:

    ')' expected
    illegal start of expression

    When I try to compile my Employee class it is referring me to MyDate class with these errors:

    Resource MyDate.java
    ')' expected
    illegal start of expression
    cannot find symbol variable MyDate

    There are 2 more classes Staff & Faculty, but they inherit constructor from Employee which does not compile cleanly so I cannot go on.

    I know I am missing something and now all I can see are letters and not making sense. Can someone please help me see what I am missing? Example would be greatly appreciated.

    Java Code:
    public class Employee extends Person
    {
      	private String office;
      	private int salary;
      	private MyDate dateHired;
    
      	public Employee ()
      	{}
    
       	public Employee(String name, String address, String phone,
    			   		String email,String office, int salary, MyDate dateHired)
      	{
      		super(name,address,phone,email);
      		this.office=office;
      		this.salary=salary;
      		this.dateHired=dateHired;
      	}
    
    	public String getOffice()
     	{
        	return office;
       	}
    
    	public int getSalary()
    	{
        	return salary;
       	}
    
    
    	public String setOffice()
     	{
        	return office;
       	}
    
    	public int setSalary()
    	{
        	return salary;
       	}
    
    
    	public String toString()
      	{
        	return super.toString() + "\nOffice:" + this.office + "\nSalary:" +
        				this.salary + "\nDate Hired" + dateHired.getMonth() +
        			"/" + dateHired.getDay() + "/" + dateHired.getYear();
      	}
    }






    Java Code:
    public class MyDate extends Employee
    {
    	int year;
      	int month;
      	int day;
    
    	public MyDate()
    		{}
    
      	public MyDate ( String office, int salary, MyDate dateHired,int year, int month, int day)
      	{
      		super(office, salary, MyDate dateHired); /// are of error
      		this.year=year;
      		this.month=month;
      		this.day=day;
      	}
    
      	public int getDay()
        {
            return day;
        }
    
      	 public int getMonth()
        {
            return month;
        }
    
      	 public int getYear()
        {
            return year;
        }
    
      	public boolean setDMY(int day, int month, int year)
       {
          boolean valid = day >= 1 && day <= 31 &&
                          month >= 1 && month <= 12;
    
          if (valid)
          {
             day = day; month = month; year = year;
          }
          return valid;
       }
    
    
      	public String toString ()
      	{
      		return super.toString()+ "Month: " + month
             + ", Day: " + day + ", Year: " + year + "]";
      	}
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Replies: 3
    Last Post: 01-21-2011, 02:37 PM
  2. constructor error in image manipulation app
    By bmcnamara in forum New To Java
    Replies: 3
    Last Post: 12-05-2009, 09:06 PM
  3. Constructor Error ?
    By sysout in forum New To Java
    Replies: 4
    Last Post: 08-25-2009, 06:39 AM
  4. why do I got this error about the constructor ?
    By aneuryzma in forum New To Java
    Replies: 4
    Last Post: 08-14-2008, 11:22 PM
  5. Error: cannot find symbol constructor
    By zoe in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 09:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •