| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 11:46:25
|
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
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 12:25:06
|
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
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 12:30:44
|
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?
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 13:04:16
|
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.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 13:20:13
|
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
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 13:23:37
|
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.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 13:29:47
|
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!
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/29/2006 14:10:20
|
stdunbar
Newbie
![[Avatar]](/images/avatar/a87ff679a2f3e71d9181a67b7542122c.png)
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 |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/30/2006 02:43:15
|
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
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/30/2006 07:52:28
|
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!
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/30/2006 07:55:34
|
carly
Newbie
Joined: 12/02/2005 08:27:22
Messages: 23
Offline
|
cheers for your help iv got it all sorted thanks
|
|
|
 |
|
|