Need help with Java program: 1 lingering error

NOBEL

Member
Aug 2, 2000
51
0
0
I am far and away very poor at programming, but I do try to do as much as Ican before I post online for help.
I finished my program, it came up with 10 errors, I fixed all but 1, the others were in syntax, but there is one that I simply can't see.
I was hoping that someone here could be my second set of eyes.

I would really appreciate it, as this assignment is due Friday at 6.

Thanks

code is posted below, you can just cut n' paste




public abstract class StaffMember
{
protected String name;
protected String address;
protected Srting phone;

public StaffMember (String fName, String homeAddress, String homePhone)
{
name= fName;
address= homeAddress;
phone= homePhone;
}

public String toString()
{
String toReturn;
toReturn ="\n Name: " + fName+ "\n Address: "+homeAddress+"\n Phone: " +homePhone;
return toReturn;
}

public abstract double pay();
}

public class Employee extends StaffMember
{
private String SSNumber;
protected double payRate;

public Employee (String fName,String homeAddress,String homePhone,String SIN, double sPayRate)
{
super(fName,homeAddress,homePhone);
setSSNumber(SIN);
setPayRate(sPayRate);
}

public Employee (String fName, String homeAddress, String homePhone)
{
super(fName,homeAddress,homePhone);
}

public double getPayRate()
{
return PayRate;
}

public String getSSNumber()
{
return SSNumber;
}

public void setSSNumber(String aSSN)
{
SSNumber=aSSN;
}

public void setPayRate(double sPay)
{
payRate=sPay;
}

public String toString ()
{
return super.toString()+ "\n Social Number: "+SSNumber;
}

public double pay()
{
return PayRate;
}

}

public class Hourly extends Employee
{
private double hoursWorked;

public Hourly (String fName, String homeAddress, String homePhone, double w)
{
super(fName,homeAddress,homePhone);
sethoursWorked(w);
}

public Hourly(String fName, String homeAddress, String homePhone, String s, double p, double w)
{
super(fName,homeAddress,homePhone);
super.setSSNumber(s);
super.setPayRate(p);
super.setHoursWorked(w);
}

public double pay()
{
double wage = getPayRate();
double paid = wage*hoursWorked;
return paid;
}

public void setHoursWorked (double w)
{
hoursWorked = w;
}

public String toString()
{
return super.toString()+ "\n Current Hours: " +hoursWorked;
}

public double getHoursWorked()
{
return hoursWorked;
}}

public class Staff
{
private StaffMember[] sMember;
public Staff()
{
sMember=new StaffMember[2];

Hourly t1= new Hourly ("Sam","123 Main Line","555-4569","425-652-124",9.5,0);
sMember[0]=t1;

Employee e =new Employee("Carla","456 Main Line","555-0789","123-456-786",6.5);
sMember[1]=e;

Hourly t2= new Hourly("Rob","998 Main Line","567-7754","542-326-586",8.55,2.0);
sMember[2]=t2;
}


public void cash()
{
double price =0.0;
for (int i=0; i<3;i++)
{
System.out.println(sMember);
price=sMember.cash();
if(price==0)
System.out.println("Thanks \n");
else
System.out.println("Paid: "+price+"\n");
System.out.println("---------------------------------------------------");
}
}

public class Firm
{
public static void main (String args[])
{
Staff nStaff=new Staff();
nStaff.cash();

}
}
 

AgentEL

Golden Member
Jun 25, 2001
1,327
0
0
One problem I see is in your toString(). Hint: "fname" isn't recognized, but "name" is. You need to use the class variable names.
 

NOBEL

Member
Aug 2, 2000
51
0
0
The compiler states that }
is missing.
I apologize for not stating the error, I thought if you ran it, that you would see the error I had.

Sorry about that!!!
 

toekramp

Diamond Member
Jun 30, 2001
8,426
2
0
Originally posted by: asleepwalking00
I think you forgot a closing bracket for class Staff... Try putting another one after the cash function.

i concur
 

NOBEL

Member
Aug 2, 2000
51
0
0
Thanks for the help, currently I am at work so I will make the change (hopefully it works) when I get home.
BTW: I'm not implying anything, I was just curious if any of you ran the program.
If not, no worries.

Thanks again
 

imported_jediknight

Senior member
Jun 24, 2004
343
0
0
Properly indenting your code helps a lot.. (it might partly be because of the forums.. but I think not.. or at least not completely)