Results 1 to 5 of 5
- 04-07-2008, 07:23 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
[SOLVED] Problem with extending classes...
Hi, I've got a homework assignment that requires us to make multiple classes in multiple files (1 class per file) and then have a main file that utilizes the classes within the other files. Here's how my classes and sub classes are setup:
employee -> paid & volunteer
paid -> hourly & monthly & executive
My files are employee.java, paid.java, volunteer.java, hourly.java, monthly.java, and executive.java; all of these are in the same package called employees. I also have a mainApp.java that utilizes the other files.
The problem I'm having is with the volunteer.java, when I compile it it gives these errors:
Error 1)
volunteer.java:13: cannot find symbol
symbol: class employee
class volunteer extends employee{
Error 2)
volunteer.java:42: cannot find symbol
symbol : variable super
location: class employees.volunteer
String top = super.toString();
And heres the code for volunteer.java:
Anyone see what's wrong?Java Code:package employees; import java.util.*; import java.io.*; import java.text.*; class volunteer extends employee{ private String type; private double earn; /*private String fname = super(fname); private String lname = super(lname); private String address = super(address);*/ public volunteer() { super(); type = "Volunteer"; earn = 0.0; } public volunteer(String first, String last, String addrs) { super(first, last, addrs); type = "Volunteer"; earn = 0.0; } public double earnings() { return this.earn; } public String toString() { String top = super.toString(); return this.type + "\n" + top; } }Last edited by Bizmark; 04-07-2008 at 11:22 PM.
- 04-07-2008, 08:15 AM #2
Welcome to the Forums! :)
Can you post what the class employee looks like? It might wise for you to also adhere to Java naming conventions. It's very easy to mistake employee for employees, only one is a package and the other is a class.. :(
At a glance, it appears the compiler can't find the employee class, nor the super or super's method toString().Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 04-07-2008, 10:32 AM #3
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
I fixed the problem, thanks though =)
- 04-07-2008, 11:09 PM #4
Care to share how you solved your problem?
Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 04-07-2008, 11:21 PM #5
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
Sure, but by the way, it took me from last night at 9:00pm to this morning at 9:30am to finish this program. It was extremely grueling and I wanted to rip my hair out by the time I finished, but it's done and I'm really proud of it :D. Anyway, the problem was that I was compiling the program from volunteer.java rather than compiling the mainApp.java file which has the main() function in it and, since it uses all my other classes in all those other .java files, it will make the class files itself. That solved that problem, but then a million other problems came up that kept me working all night long, but anyway, its done.
Similar Threads
-
[SOLVED] Problem with setVisible(); on LINUX
By lepetitprince in forum AWT / SwingReplies: 9Last Post: 11-22-2008, 04:14 PM -
[SOLVED] alignment problem
By nanimtech in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-10-2008, 01:23 PM -
[SOLVED] file i/o problem
By aytidaalkuhs in forum New To JavaReplies: 3Last Post: 04-06-2008, 06:42 PM -
[SOLVED] Actionevent problem
By Cymro in forum New To JavaReplies: 3Last Post: 04-04-2008, 07:11 AM -
[SOLVED] Problem with code - inheritence
By yalla in forum New To JavaReplies: 1Last Post: 03-30-2008, 06:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks