aspose file tools*
The moose likes Beginning Java and the fly likes Help with an Inheritance issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with an Inheritance issue " Watch "Help with an Inheritance issue " New topic
Author

Help with an Inheritance issue

robert walter
Greenhorn

Joined: Apr 08, 2004
Posts: 2
Ok, I'm getting some errors in my SalesEmployee class which extends Employee class. The error has to do with a variable that isnt in the employee class called "managerName". Its in the SalesEmployee class because thats how the teacher wants it. Did I declare it wrong in my SalesEmployee class or what am I doing wrong. Here is my SalesEmployee class and the main class which tests the class.

My errors are:
C:\cis163\Project5_2\src\Project5_2.java:62: cannot resolve symbol
symbol : constructor Employee (java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,short,double,java.lang.String,Company)
location: class Employee
Employee anEmployee = new Employee( employeeFName,employeeLName,employeeAddress,
^
C:\cis163\Project5_2\src\Project5_2.java:108: cannot resolve symbol
symbol : variable aManagerName
location: class Project5_2
aManagerName.setManagerName(managerName);
^
C:\cis163\Project5_2\src\Project5_2.java:130: cannot resolve symbol
symbol : variable aManagerName
location: class Project5_2
System.out.println( "Managers name; " + aManagerName.getManagerName() );
^
Thanks
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

It is as the error said.
1. You are calling constructor which has a managerName, and Empoyee class has no such constructor. You have to call SalesEmployee constructor instead.
2. Again you have the employee variable as Employee object, which does not have setManagerName() method.
To solve 1 & 2, you might want to change the Class that you use in the test class, from

to

For error #3, it is because you never declared aManagerName object.
What exactly do you want it to be?
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

(was moved away by moving the thread while I'm editing...)
Could you post some more 'System.out.println'-statements, to prove, this is really an intermediate question?
To get a better answer you have to do something:
Eliminate comments which aren't useful for intermediate programers:

... and mark the error-line (62)

If anEmployee is a new SalesEmployee, perhaps the constructor works?
(and if you bring managerName and company to a consistent order)
The next two errors seem to be related to each other:

But if YOU did the work of cutting it, you had chances to find the error on your own.
[ April 20, 2004: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

I'm giving up, editing my post.
These ubb-thing is somehow buggy. Lines are eliminated from the middle of the postings...
robert walter
Greenhorn

Joined: Apr 08, 2004
Posts: 2
Well thanks for the help. I fixed the snippet

and then fixed

and

After those changes I have more errors, which are
C:\cis163\Project5_2\src\Project5_2.java:108: cannot resolve symbol
symbol : method setManagerName (java.lang.String)
location: class Employee
anEmployee.setManagerName(managerName);
^
C:\cis163\Project5_2\src\Project5_2.java:130: cannot resolve symbol
symbol : method getManagerName ()
location: class Employee
System.out.println( "Managers name; " + anEmployee.getManagerName() );
^
I already declared the variable in my SalesEmployee class so I dont understand the error
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with an Inheritance issue