import java.util.Scanner;
interface Employee{
int getSalary();
}
class Programmer implements Employee{
int salary ;
Programmer(){
salary = 5000;
}
@Override
public int getSalary(){
return salary;
}
}
class SeniorProgrammer extends Programmer{
SeniorProgrammer(){
super();
salary = 5000;
}
@Override
public int getSalary(){
return salary + 5000;
}
}
class Manager extends SeniorProgrammer{
Manager(){
super();
this.salary += 5000;
}
@Override
public int getSalary(){
return salary + 5000 + 5000;
}
}
class ProgrammerFactory{
public Programmer makeProgrammer(String pos){
if(pos.equals("Programmer")){
return new Programmer();
}else if(pos.equals("SeniorProgrammer")){
return new SeniorProgrammer();
}else if(pos.equals("Manager")){
return new Manager();
}else {
return null;
}
}
}
public class factory{
public static void main(String[] args){
ProgrammerFactory factory = new ProgrammerFactory();
Employee Programmer = factory.makeProgrammer("Programmer");
Employee SeniorProgrammerProgrammer = factory.makeProgrammer("SeniorProgrammer");
Employee Manager = factory.makeProgrammer("Manager");
Manager.getSalary();
Programmer.getSalary();
SeniorProgrammer.getSalary();
}
}