abstract class Employee
{
public double s;
public double c;
public double w;
public int q;
public int h;
abstract void earning();
}
class Boss extends Employee
{
private String Name;
public Boss(String Name,double s)
{
this.Name = Name;
this.s = s;
}
public void earning()
{
if (s<0) {s=0;}
System.out.println("Boss:" + Name + s);
}
}
class Commission extends Employee
{private String Name;
public Commission(String Name,double s,double c,int q)
{
this.Name = Name;
this.s = s;
this.c = c;
this.q = q;
}
public void earning()
{
if (s<0) {s=0;}
if (c<0) {c=0;}
if (q<0) {q=0;}
System.out.println("Commission Worker:" + Name + (s+(c*q)));
}
}
class Piece extends Employee
{private String Name;
public Piece(String Name,double w,int q)
{
this.Name = Name;
this.s = s;
this.w = w;
this.q = q;
}
public void earning()
{
if (w<0) {w=0;}
if (q<0) {q=0;}
System.out.println("Piece Worker:" + Name + (w*q));
}
}
class Hourly extends Employee
{private String Name;
public Hourly(String Name,double w ,int h)
{
this.Name = Name;
this.s = s;
this.w = w;
this.h = h;
}
public void earning()
{
if (w<0) {w=0;}
if (h<0) {h=0;}
System.out.println("Hourly Worker:" + Name +(w*h));
}
}
public class java1227
{
public static void main(String[] args)
{
Employee m;
Boss m1 = new Boss("John ",25000);
Boss m2 = new Boss("Mary ",-1400);
Commission m3 = new Commission("Hellen ",10000,150,10);
Commission m4 = new Commission("Hellenay ",-900,100,20);
Piece m5 = new Piece("Joe ",5000,3);
Piece m6 = new Piece("Johnny ",4000,-2);
Hourly m7 = new Hourly("Kiren ",300,100);
Hourly m8 = new Hourly("Karo ",200,-99);
m = m1;
m.earning();
m = m2;
m.earning();
m = m3;
m.earning();
m = m4;
m.earning();
m = m5;
m.earning();
m = m6;
m.earning();
m = m7;
m.earning();
m = m8;
m.earning();
}
}
留言列表