[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
Please help me before I kill myself  XML
Forum Index » Java Programming
Author Message
carly

Newbie

Joined: 12/02/2005 08:27:22
Messages: 23
Offline

hi Im having trouble compiling a load of things can anyone tell me why -

public class HourlyPaid extends Job
{
private double ratePerHour;
private int hoursWorked;
private double totalCost;

public HourlyPaid (int jobNumber, String customerName, boolean paid, double costOfMaterials, double rate, int hours);
{
super (jobNumber, customerName, paid, costOfMaterials);
ratePerHour = rate;
hoursWorked = hours;
}

public double calulateTotalCost();{
double cost = ratePerHour * hoursWorked;
double totalCost = cost + materialsCost;
}

public void setRatePerHour (double rate) {ratePerHour = rate;}
public void setHoursWorked (int hours) {hoursWorked = hours;}
public double getRatePerHour(){return ratePerHour;}
public int getHoursWorked(){return hoursWorked;}
public double getCost() {return totalCost;}

public void displayHourlyPaidDetails()
{
printHeader();
super.displayDetails();
System.out.println("The rate per hour is :"+ ratePerHour);
System.out.println("The number of hours worked :" + hoursWorked);
}

private void printHeader()
{
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println ("Hourly Paid Job Details");
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
}

the errors say

HourlyPaid.java:7: missing method body, or declare abstract
public HourlyPaid (int jobNumber, String customerName, boolean paid, dou
ble costOfMaterials, double rate, int hours);
^
HourlyPaid.java:9: call to super must be first statement in constructor
super (jobNumber, customerName, paid, costOfMaterials);
^
HourlyPaid.java:10: cannot find symbol
symbol : variable rate
location: class HourlyPaid
ratePerHour = rate;
^
HourlyPaid.java:11: cannot find symbol
symbol : variable hours
location: class HourlyPaid
hoursWorked = hours;
^
HourlyPaid.java:14: missing method body, or declare abstract
public double calulateTotalCost();{
^
5 errors

theres more if anyone feels they can help any help would be greatly appreciated!
Cheers
tfecw

Newbie

Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline

You've got some ';'s at the end of your methods you probably don't want there

aim icon
carly

Newbie

Joined: 12/02/2005 08:27:22
Messages: 23
Offline

ok iv changed a few things and now i get
2 errors

HourlyPaid.java:10: ';' expected
ratePerHour = rate;
^
HourlyPaid.java:29: ';' expected
super.displayDetails();
^
2 errors

i dont get this as both of these hav ;'s at the end!?
any ideas?
tfecw

Newbie

Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline

the ; errors can be tricky, you've got to check around the line number (usually before the line) and look for a line that you missed a ; on.
aim icon
carly

Newbie

Joined: 12/02/2005 08:27:22
Messages: 23
Offline

ok Iv sorted out the ;'s now iv got this -

HourlyPaid.java:18: missing return statement
}
^
1 error

any ideas - its from the code i first posted by the way
tfecw

Newbie

Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline


HourlyPaid.java:18: missing return statement


The error message is fairly clear...you're missing a return statement

If you declare a return type of something other than void, you need to have your method return something.
aim icon
carly

Newbie

Joined: 12/02/2005 08:27:22
Messages: 23
Offline

Thank you very much another 2 classes are compiling now!!!

However any idea what the following means -

TestFixedRateJob.java:14: cannot find symbol
symbol : method setLabourCost(double)
location: class Job
aJob.setLabourCost (5.10);
^
TestFixedRateJob.java:27: cannot find symbol
symbol : method getLabourCost()
location: class Job
System.out.println(aJob.getLabourCost( ));
^
2 errors

this is for this code -
public class TestFixedRateJob
{
public static void main(String []args)

{
System.out.println("Testing Fixed Rate Job class");
System.out.println("---------------------------------------");

Job aJob = new Job();
aJob.setJobNo (123);
aJob.setCustomer ("Staffs");
aJob.setPaid (false);
aJob.setMaterialsCost (10.50);
aJob.setLabourCost (5.10);

System.out.println("Testing displayDetails "+"job number 123 customer Staffs paid false materials cost 10.50 labour cost 5.10");
aJob.displayDetails () ;
System.out.println("Testing getJobNo - 123 expected");
System.out.println(aJob.getJobNo( ));
System.out.println("Testing getCustomer - Staffs expected");
System.out.println(aJob.getCustomer( ));
System.out.println("Testing getPaid - false expected");
System.out.println(aJob.getPaid( ));
System.out.println("Testing getMaterialsCost - 10.50 expected");
System.out.println(aJob.getMaterialsCost( ));
System.out.println("Testing getLabourCost - 5.10 expected");
System.out.println(aJob.getLabourCost( ));
}
}

I really appreciate this!
stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline

Do you have the code for Job? You're creating a new Job class but you showed the code for the HourlyPaid class. That extends Job but the compiler will look in Job to see what methods exist and what their signature is.

Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
carly

Newbie

Joined: 12/02/2005 08:27:22
Messages: 23
Offline

public class Job
{
public int jobNo;
public String customer;
public boolean paid;
public double materialsCost;


public Job (){}

public Job (int jobNumber, String customerName, boolean paid, double costOfMaterials)
{jobNo = jobNumber; customer = customerName; paid = false; materialsCost = costOfMaterials;}

public void setJobNo (int jobNumber) {jobNo = jobNumber;}
public void setCustomer (String customerName) {customer = customerName;}
public void setPaid (boolean paid) {paid = false;}
public void setMaterialsCost (double costOfMaterials) {materialsCost = costOfMaterials;}

public int getJobNo () {return jobNo;}
public String getCustomer () {return customer;}
public boolean getPaid () {return paid;}
public double getMaterialsCost () {return materialsCost;}

public void displayDetails()
{
printHeader();
System.out.println("Job Number is :"+ jobNo);
System.out.println("Customer is :"+ customer);
System.out.println("Has the job been paid for? :"+ paid);
System.out.println("Cost of Materials :"+ materialsCost);
}

private void printHeader()
{
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println ("Job Details");
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
}

Job Class
tfecw

Newbie

Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline

You errors are saying you don't have a setLaborCost or a getLaborCost method in your Job class...which you don't.

Googling error messages will usually yield good information on how to solve the error.

Good Luck!
aim icon
carly

Newbie

Joined: 12/02/2005 08:27:22
Messages: 23
Offline

cheers for your help iv got it all sorted thanks
 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle