Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CURSO JAVA POO. CONSTRUCCION DE OBJETOS. VIDEOS 34-35
- //UNICO FICHERO FUENTE
- package poo;
- import java.util.*;
- public class Uso_Empleados {
- public static void main(String[] args) {
- Jefatura jefe_RRHH= new Jefatura("LUCIANO", 999999, 1996, 07, 23);
- jefe_RRHH.estableceIncentivo(1);
- jefe_RRHH.dameSueldo();
- Empleado misEmpleados[]= new Empleado[6];
- misEmpleados[0]= new Empleado("Paco Gomez", 10, 1990, 12, 17);
- misEmpleados[1]= new Empleado("Ana Lopez",50, 1995, 06, 02);
- misEmpleados[2]= new Empleado("Maria Martin", 15, 2002, 03, 15);
- misEmpleados[3]= new Empleado("asdf", 60, 2002, 03, 15);
- misEmpleados[4]= jefe_RRHH;//POLIMORFISMO EN ACCION - PRINCIPIO EN ACCION
- misEmpleados[5]= new Jefatura("MARIA", 1, 1999, 5, 26);
- Jefatura jefe_Finanzas= (Jefatura)misEmpleados[5];
- jefe_Finanzas.estableceIncentivo(100000);
- Empleado director_comercial= new Jefatura("DIRECTOR", 5000, 2012, 02, 32);
- Comparable ejemplo= new Empleado("ELI", 9500, 1996, 02, 13);
- if(director_comercial instanceof Empleado){
- System.out.println("ES DE TIPO JEFATURA");
- }
- if(ejemplo instanceof Comparable){
- System.out.println("IMPLEMENTA LA INTERFAZ COMPARABLE");
- }
- System.out.println(jefe_Finanzas.tomar_decisiones("RENUNCIAR"));
- System.out.println(jefe_RRHH.tomar_decisiones("SOY PUTO"));
- //REFUNDICION:
- double pene= 5.6;
- int pene1= (int)pene;
- System.out.println(jefe_Finanzas.establece_bonus(500));
- //ORDENAMIENTO SORT
- Arrays.sort(misEmpleados);
- //OPCION 2:
- for(Empleado e: misEmpleados){
- System.out.println("NOMBRE: " +e.dameNombre()
- +"\nSUELDO: " +e.dameSueldo()
- +"\nFECHA ALTA: " +e.dameFechaContrato()
- +"ID: " +e.dameId()
- +"\n-----------------");
- }
- }
- }
- class Empleado implements Comparable, Trabajadores{
- private String nombre;
- private double sueldo;
- private Date altaContrato;
- private int id;
- public static int idnext=1;
- public Empleado(String nom, double sue, int agno, int mes, int dia){//CONSTRUCTORES
- nombre=nom;
- sueldo=sue;
- GregorianCalendar calendario = new GregorianCalendar(agno, mes-1, dia);
- altaContrato= calendario.getTime();
- id=idnext;
- idnext++;
- }
- public double establece_bonus(double gratificacion){
- return Trabajadores.bonus_base+gratificacion;
- }
- public Empleado(String nom){//SOBRE CARGA DE CONSTRUCTOR
- this(nom, 99999, 2017, 01, 01);
- }
- public String dameNombre(){//GETTER
- return nombre;
- }
- public double dameSueldo(){//GETTER
- return sueldo;
- }
- public Date dameFechaContrato(){//GETTER
- return altaContrato;
- }
- public int dameId(){
- return id;
- }
- public void subeSueldo(double porcentaje){//SETTER
- double aumento=sueldo*porcentaje/100;
- sueldo+=aumento;
- }
- //COMPARE TO
- public int compareTo(Object miObjeto){
- Empleado otroEmpleado=(Empleado)miObjeto;
- if(this.sueldo<otroEmpleado.sueldo){
- return -1;
- }
- if(this.sueldo>otroEmpleado.sueldo){
- return 1;
- }
- return 0;
- }
- }
- class Jefatura extends Empleado implements Jefes{
- private double incentivo;
- public Jefatura(String nom, double sue, int agno, int mes, int dia){
- super(nom, sue, agno, mes, dia);
- }
- public void estableceIncentivo(double b){
- incentivo=b;
- }
- public String tomar_decisiones(String decision){
- return "UN MIEMBRO DE LA DIRECCION HA TOMADO LA DEICCION DE: "+decision;
- }
- public double establece_bonus(double gratificacion){
- double prima=2000;
- return Trabajadores.bonus_base+gratificacion+prima;
- }
- public double dameSueldo(){//GETTER
- double sueldoJefe= super.dameSueldo();
- return sueldoJefe + incentivo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement