Results 1 to 5 of 5
  1. #1
    Bizmark is offline Member
    Join Date
    Apr 2008
    Posts
    4
    Rep Power
    0

    Default [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:
    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;
    	}
    }
    Anyone see what's wrong?
    Last edited by Bizmark; 04-08-2008 at 12:22 AM.

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    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)

  3. #3
    Bizmark is offline Member
    Join Date
    Apr 2008
    Posts
    4
    Rep Power
    0

    Default

    I fixed the problem, thanks though =)

  4. #4
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    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)

  5. #5
    Bizmark is offline Member
    Join Date
    Apr 2008
    Posts
    4
    Rep Power
    0

    Default

    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

  1. [SOLVED] Problem with setVisible(); on LINUX
    By lepetitprince in forum AWT / Swing
    Replies: 9
    Last Post: 11-22-2008, 05:14 PM
  2. [SOLVED] alignment problem
    By nanimtech in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-10-2008, 02:23 PM
  3. [SOLVED] file i/o problem
    By aytidaalkuhs in forum New To Java
    Replies: 3
    Last Post: 04-06-2008, 07:42 PM
  4. [SOLVED] Actionevent problem
    By Cymro in forum New To Java
    Replies: 3
    Last Post: 04-04-2008, 08:11 AM
  5. [SOLVED] Problem with code - inheritence
    By yalla in forum New To Java
    Replies: 1
    Last Post: 03-30-2008, 07:11 AM

Posting Permissions

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