Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   can anyone hlep me (http://www.go4expert.com/forums/hlep-t1050/)

chasey 23Jul2006 19:22

can anyone hlep me
 
im really new to progeramming java im trying to do the following
"SalesStaff inherits from Employee and represents an employee who has a basic yearly salary, paid weekly over 52 weeks, but who can also earn a weekly bonus depending on performance during the weekThe employee is awarded bonus points for the week and each bonus point earns 20 extra on the weekly pay for that week only"

i just tired the following code ,
Code:

private double bonusPoints (){
return super inputSalary / 52.0 + bonusPoints * 20;
}

but it comes up with the following errors
Code:

SalesStaff.java:13: '.' expected
return super inputSalary / 52.0 + bonusPoints * 20;
            ^
SalesStaff.java:13: <identifier> expected
return super inputSalary / 52.0 + bonusPoints * 20;
                                                  ^
2 errors


chasey 23Jul2006 19:23

Re: can anyone hlep me
 
this is the code for all the class

Code:

public class SalesStaff extends Employee {
//instance variables
double bonusPoints;
//constructor
public SalesStaff (String inputName, String inputSurname, String inputPayRef, double inputSalary,String inputCar)
{
super (inputName , inputSurname , inputPayRef ,inputSalary);

}

//other methods
private double bonusPoints (){
return super inputSalary / 52.0 + bonusPoints * 20;
}


public void showDetails(){
 super.showDetails();
}

}//End of class definition


Amit Dave 24Jul2006 16:26

Re: can anyone hlep me
 
hi chasey,

I guess you forgot a . (dot) after super keyword in this line :

return super inputSalary / 52.0 + bonusPoints * 20;


just replace the above line with this :

return super.inputSalary / 52.0 + bonusPoints * 20;

This will solve your purpose,
you can send the code for Employee class also if there are any further issues.

Thanks and Regards
Amit Dave

chasey 24Jul2006 17:02

Re: can anyone hlep me
 
i just tried

Code:

private double bonusPoints (){
return super.getSalary / 52.0 + bonusPoints * 20;
}

but it come up with the following error

Code:

SalesStaff.java:13: cannot resolve symbol
symbol  : variable getSalary 
location: class Employee
return super.getSalary / 52.0 + bonusPoints * 20;
                ^

i aslo tired this
Code:

return this.getSalary / 52.0 + bonusPoints * 20;
}

but this came up with following errror
Code:

SalesStaff.java:13: cannot resolve symbol
symbol  : variable getSalary 
location: class SalesStaff
return this.getSalary / 52.0 + bonusPoints * 20;
      ^

im very new to java please help

here is the emplyee classs
Code:

public class Employee {
 //instance variables
 private String fName;
 private String sName;
 private String payReference;
 private double annualSalary;
 //constructor
 public Employee (String inputName, String inputSurname, String inputPayRef, double inputSalary)
 {
 fName = inputName;
 sName = inputSurname;
 payReference = inputPayRef;
 annualSalary = inputSalary;
 }
 //The next 4 methods are ACCESSOR methods
 public String getfName(){
 return fName;
 }
 public String getsName(){
 return sName;
 }
 
 public String getPayReference(){
 return payReference;
 }
 public double getSalary(){
 return annualSalary;
 }
 //The next 4 methods are SETTING methods
 public void setName(String newName){
 fName = newName;
 }
 public void setsName(String newsName){
 sName = newsName;
 }
 public void setPayReference(String newPayRef){
 payReference = newPayRef;
 }
 public void setSalary(double newSalary){
 annualSalary = newSalary;
 }
 
 public void showDetails(){
 System.out.println("Employee Name    : " + this.getfName()  );
 System.out.println("Employee Surname    : " + this.getsName()  );
 System.out.println("Pay Reference        : " + this.getPayReference());
 System.out.println("Annual Salary        : " + this.getSalary());
 }
 
 }//End of class definition


Amit Dave 24Jul2006 17:23

Re: can anyone hlep me
 
Hi

Just copy this code below in a java file and name it "SalesStaff.java" and try to compile it.
It will compile successfully as it did for me.
Code: JAVA

class Employee {
    //instance variables
    private String fName;
    private String sName;
    private String payReference;
    private double annualSalary;
    //constructor
    public Employee (String inputName, String inputSurname, String inputPayRef, double inputSalary)
    {
        fName = inputName;
        sName = inputSurname;
        payReference = inputPayRef;
        annualSalary = inputSalary;
    }
    //The next 4 methods are ACCESSOR methods
    public String getfName(){
        return fName;
    }
    public String getsName(){
        return sName;
    }
   
    public String getPayReference(){
        return payReference;
    }
    public double getSalary(){
        return annualSalary;
    }
    //The next 4 methods are SETTING methods
    public void setName(String newName){
        fName = newName;
    }
    public void setsName(String newsName){
        sName = newsName;
    }
    public void setPayReference(String newPayRef){
        payReference = newPayRef;
    }
    public void setSalary(double newSalary){
        annualSalary = newSalary;
    }
   
    public void showDetails(){
        System.out.println("Employee Name     : " + this.getfName()  );
        System.out.println("Employee Surname     : " + this.getsName()  );
        System.out.println("Pay Reference         : " + this.getPayReference());
        System.out.println("Annual Salary         : " + this.getSalary());
    }
   
}//End of class definition




public class SalesStaff extends Employee {
    //instance variables
    double bonusPoints;
    //constructor
    public SalesStaff (String inputName, String inputSurname, String inputPayRef, double inputSalary,String inputCar)
    {
        super (inputName , inputSurname , inputPayRef ,inputSalary);
       
    }
   
    //other methods
    private double bonusPoints (){
        return super.getSalary() / 52.0 + bonusPoints * 20;
    }
   
   
    public void showDetails(){
        super.showDetails();
    }
   
}//End of class definition
 

Regards
Amit Dave

chasey 25Jul2006 15:40

Re: can anyone hlep me
 
this is what i have so far on a test class can someone help with it , is there a way of of test all the the class in test? im never done one before

Code:

public class EmpolyeeTestClass
{
  public static void main(String[] args)
  {
   
         
        }
}


shabbir 25Jul2006 22:08

Re: can anyone hlep me
 
Can you explain a bit more about your test routine. The code you have is just what is the minimum needed to start the execution.

chasey 25Jul2006 23:13

Re: can anyone hlep me
 
hi i want to test the emplyee class , i want to test the setting of the names and to see if they work, then i want to test the other class

shabbir 26Jul2006 04:41

Re: can anyone hlep me
 
Then create the object of the Employee class and invoke the methods you want to test

chasey 26Jul2006 16:43

Re: can anyone hlep me
 
this is what i have done can help me finish it?
Code:

public class EmpolyeeTestClass
{
  public static void main(String[] args)
  {
    System.out.println ("Please type the emplyee name:");
String fname = EasyIn.getString( );
System.out.println ("Please type the cemplyee secound name :");
String sName = EasyIn.getString( );

         
        }
}

the easy in is a class that i got with the cd that came with the book , can you help show the details i put e.g emplyee name


All times are GMT +5.5. The time now is 06:41.