Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2005

Tip: Looking for answers? Try searching our database.

Error during compile using classes

Thread view: 
Kris M - 11 Sep 2005 22:32 GMT
I am getting a compile error that says cant find symbol for the constructor
Worker() in class worker when the class worker has a constructor
method..heres the code from the parent(worker), child class (Executive), and
used class J2P1.java. Any suggestions to get past the compile error? Im
using jdk1.5.0_01.
TIA Kris
//Executive class for use with J2P1.java

public class Executive extends Worker

{

protected float annualSalary;

public Executive (String name)

{

Super(name);

}

public void setAnnualSalary(float amt)

{

annualSalary = amt;

}

public float grossWage()

{

return annualSalary / 12.0f;

}

}// ends class executive

//---------------------------------------

// Public class worker used in J2P1.java

public class Worker

{

protected String nameOfWorker;

protected float hoursWorked;

protected float rateOfPay;

public Worker(String name)

{

nameOfWorker = name;

}

public String getWorkerName()

{

return nameOfWorker;

}

public void setHours(float hrs)

{

hoursWorked = hrs;

}

public void setRate(float r)

{

rateOfPay = r;

}

public float grossWage()

{

return hoursWorked * rateOfPay;

}

}// end class worker

//J2P1.java using inheritance and polymorphism

public class J2P1

{

static void DisplayGrossWage(Worker person)

{

system.out.println(person.getName() + "earns $ " + person.grossWage());

}

public static void main(String [] args)

{ Worker storeman = new Worker("Fred");

storeman.setHours(40.0f);

storeman.setRate(10.0f);

DisplayGrosswages(storeman);

Executive manager = new Executive("James");

manager.setSalary(120000F);

DisplayGrosswage(manager);

Salesperson region1 = new Salesperson("Laura");

region1.setCommisionRate(24.0f);

region1.setPayPeriod(12.0f);

region1.setSalesToDate(435000.0f);

DisplayGrossWages(region1);

}//end main

}//end class J2P1
Roedy Green - 12 Sep 2005 04:45 GMT
>}// end class worker
Java is case sensitive. You will get is serious trouble if you don't
get in the habit of being accurate and consistent with your caps.

Class names start with a capital letter, always.

Also the *.java file names  had better have the right caps too.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Remi Arntzen - 12 Sep 2005 05:55 GMT


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.