import java.util.Scanner; |
public class Main{ |
public static void main(String[] args) { |
Scanner scan = new Scanner(System.in); |
int salary1 = scan.nextInt(); |
Employee E1 = new Manager(salary1); |
System.out.println(E1.getSalary()); |
int salary2 =scan.nextInt(); |
int royalty =scan.nextInt(); |
Employee E2 = new Salesman(salary2, royalty); |
System.out.println(E2.getSalary()); |
int salary3 = scan.nextInt(); |
int num =scan.nextInt(); |
Employee E3 = new Worker(num, salary3); |
System.out.println(E3.getSalary()); |
scan.close(); |
} |
} |
abstract class Employee{ |
private int salary; |
public Employee( int s) { |
salary = s; |
} |
public int getS() { |
return salary; |
} |
public abstract int getSalary(); |
} |
class Manager extends Employee{ |
public Manager( int s) { |
super (s); |
} |
public int getSalary() { |
return super .getS(); |
} |
} |
class Salesman extends Employee{ |
private int royalty; |
public Salesman( int s, int r) { |
super (s); |
royalty = r; |
} |
public int getSalary() { |
return super .getS()+royalty; |
} |
} |
class Worker extends Employee{ |
private int num; |
public Worker( int s, int n) { |
super (s); |
num = n; |
} |
public int getSalary() { |
return super .getS()*num; |
} |
} |