You are on page 1of 2

package testing;

public class Employee {


String name, title;
public Employee (String n, String t){
this.name = n;
this.title = t;
}
public String toString()
{
return "Name:" +name+
",Title:" +title;

}
}

package testing;
public class Worker extends Employee {
float hour, rate;
public Worker(String n, float h, float r) {
super(n,"Worker");
hour = h;
rate = r;
}
public float getSalary()
{
return hour*rate;

}
@Override
public String toString()
{
return super.toString()+
"Hours worked: " +hour
+",Rate per hour:"+rate+"Your Salary is "+getSalary();
}

}
package testing;
public class WorkerClient {
public static void main(String []args)
{
Worker w = new Worker("Jun Ming",24,10);
System.out.println(w.toString());

You might also like