• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Help with an Inheritance issue

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(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 ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Their achilles heel is the noogie! Give them noogies tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic