Question

I Have a problem with my JAVA class "Directivo". In the " public double sueldo() "...

I Have a problem with my JAVA class "Directivo". In the " public double sueldo() " method, the instruction say "Calculate the salary of a Directivo the following way: Invoke method salary of the father and add him the extra bonus"

My question is : How can I do this ? how can i implement that instruction in the public double sueldo() method

public class Directivo extends Planta implements Administrativo{

   private double bonoExtra;

   public Directivo( String nom, String ape, int antiguedad, boolean[] prestaciones, double pagoSemanal, double bono, String nombrePuesto) {
       super( nom, ape, antiguedad, pagoSemanal, prestaciones);
       setBono(bono);
       setNombrePuesto(nombrePuesto);
   }
   public void setBono( double bono ) {
      
       if(bono >0 && bono <= BONO_MAXIMO)
           this.bonoExtra=bono;
   }

   public double sueldo() {
  
      
      
   }
  
    public void setNombrePuesto(String nombre){
       this.nombrePuesto = nombre;
   }
public String toString() {
       return "\n\n*** Directivo ***\n" + super.toString() + "\nCon bono extra de: " + this.bonoExtra;
   }
  
}

EMPLEADO CLASS

public abstract class Empleado {

   protected String nombre;
   protected String apellido;
   protected int antiguedad;
  
  
   public Empleado( String nom, String ape, int antiguedad ) {
       nombre = new String ( nom );
       apellido = new String( ape );
      
       if (antiguedad > 0)
           this.antiguedad = antiguedad;
   }  

   public String getNombre() {
       return nombre;
   }

   public String getApellido() {
       return apellido;
   }
  
   public void setAntiguedad(int antiguedad) {
       if (antiguedad > this.antiguedad)
           this.antiguedad = antiguedad;
   }

   abstract double sueldo();
  
   public String toString() {
       return "\nNombre: " + this.nombre + "\nApellido: " + this.apellido + "\nAntiguedad: " + this.antiguedad;
   }
}

PLANTA CLASS

public class Planta extends Empleado{
  
protected double pagoSemanal;
protected boolean[] prestaciones;
protected double diaVacaciones;
protected String nombrePuesto;

private static final String [] PRESTACIONES = {"Vales despensa", "Afore", "Infonavit", "Vacaciones Semana Santa",
"Vacaciones Verano", "Descuento proveedores afiliados", "Seguro de auto", "Seguro de vida"};

private static final double [] PAGO_PRESTACIONES = {1000, 0.2, 0.1, 7, 2, 0.25, 5000, 25000};   
private static final double PORCENTAJE_PLANTA = 0.1;   
private static final int MAXIMO_SUELDO = 25000;

public Planta( String nom, String ape, int antiguedad, double pagoSemanal, boolean[] prestaciones) {
super (nom,ape,antiguedad);
this.prestaciones = new boolean[prestaciones.length];
for (int i = 0; i< prestaciones.length; i++)
this.prestaciones[i] = prestaciones[i];

if(pagoSemanal>= 0 && pagoSemanal <= Planta.MAXIMO_SUELDO)
this.pagoSemanal = pagoSemanal;
else
this.pagoSemanal = 0.0;

this.diaVacaciones = this.pagoSemanal * this.antiguedad * Planta.PORCENTAJE_PLANTA;

}

private String regresaPrestaciones() {

String s = "";

for (int i = 0; i< this.prestaciones.length;i++)
if(this.prestaciones[i] == true)
s +=PRESTACIONES[i];
return s;

}

public double sueldo() {

double sueldo = this.pagoSemanal;

  
for (int i = 0; i< this.prestaciones.length; i++)
{
if(this.prestaciones[i])
{   
if (i == 0 || i == 6 || i == 7)
sueldo += PAGO_PRESTACIONES[i];
  
if (i == 1 || i == 2 || i == 5)
sueldo += PAGO_PRESTACIONES[i] * pagoSemanal;

if (i == 3 || i == 4)
sueldo += PAGO_PRESTACIONES[i] * this.diaVacaciones;
}
}
return sueldo;
}

public void setPagoSemanal( double pagoSemanal ) {
if (pagoSemanal > 0 && pagoSemanal <= MAXIMO_SUELDO)
this.pagoSemanal = pagoSemanal;
}

public String toString() {
return "\n*** Empleado de Planta ***\n" + super.toString() + "\nCon puesto: " + this.getNombrePuesto() +
"\nPago semanal: " + this.pagoSemanal + "\nSueldo integrado: " + this.sueldo() + "\nPrestaciones: " + this.regresaPrestaciones();
}

public String getNombrePuesto() {
return this.nombrePuesto;
}

}

ADMINISTRATIVO INTERFACE


public interface Administrativo {

   double BONO_MAXIMO = 10000;
  
   String administrar();
  
   String definirAumentos();
  
   String reportarLogros();
  
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

// Directivo.java

public class Directivo extends Planta implements Administrativo {

      private double bonoExtra;

      public Directivo(String nom, String ape, int antiguedad,

                  boolean[] prestaciones, double pagoSemanal, double bono,

                  String nombrePuesto) {

            super(nom, ape, antiguedad, pagoSemanal, prestaciones);

            setBono(bono);

            setNombrePuesto(nombrePuesto);

      }

      public void setBono(double bono) {

            if (bono > 0 && bono <= BONO_MAXIMO)

                  this.bonoExtra = bono;

      }

      public double sueldo() {

            // calling sueldo method of super class and adding extra bonus to it,

            // returning the sum total.

            return super.sueldo() + bonoExtra;

      }

      public void setNombrePuesto(String nombre) {

            this.nombrePuesto = nombre;

      }

      public String toString() {

            return "\n\n*** Directivo ***\n" + super.toString()

                        + "\nCon bono extra de: " + this.bonoExtra;

      }

      @Override

      public String administrar() {

            return null;

      }

      @Override

      public String definirAumentos() {

            return null;

      }

      @Override

      public String reportarLogros() {

            return null;

      }

}

Add a comment
Know the answer?
Add Answer to:
I Have a problem with my JAVA class "Directivo". In the " public double sueldo() "...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the...

    NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the current displayed customer PLEASEEEEEEEEEE package bankexample; import java.util.UUID; public class Customer { private UUID id; private String email; private String password; private String firstName; private String lastName;    public Customer(String firstName, String lastName, String email, String password) { this.id = UUID.randomUUID(); this.firstName = firstName; this.lastName = lastName; this.email = email; this.password = password; } public String getFirstName() { return firstName; } public void setFirstName(String...

  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

  • The software I use is Eclipse, please show how to write it, thanks. GeometricObject class public...

    The software I use is Eclipse, please show how to write it, thanks. GeometricObject class public abstract class GeometricObject { private String color = "white"; private boolean filled; private java.util.Date dateCreated; protected GeometricObject() { dateCreated = new java.util.Date(); } protected GeometricObject(String color, boolean filled) { dateCreated = new java.util.Date(); this.color = color; this.filled = filled; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public boolean isFilled() { return filled; } public...

  • Copy the program AmusementRide.java to your computer and add your own class that extends class AmusementRide....

    Copy the program AmusementRide.java to your computer and add your own class that extends class AmusementRide. Note: AmusementRide.java contains two classes (class FerrisWheel and class RollerCoaster) that provide examples for the class you must create. Your class must include the following. Implementations for all of the abstract methods defined in abstract class AmusementRide. At least one static class variable and at least one instance variable that are not defined in abstract class AmusementRide. Override the inherited repair() method following the...

  • Java Double Max Function I need help with this top problem. The bottom is the assignment...

    Java Double Max Function I need help with this top problem. The bottom is the assignment // return Double .NEGATIVE-INFINİTY if the linked list is empty public double max return max (first); h private static double max (Node x) f e I TODO 1.3.27 return 0; 1 package algs13; 2 import stdlib.*; 4 public class MyLinked f static class Node public Node() t 1 public double item; public Node next; 10 int N; Node first; 12 13 14 public MyLinked...

  • CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE....

    CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE. SAME CODE SHOULD BE USED FOR THE DOCUMENTATION PURPOSES. ONLY INSERT THE JAVA DOC. //Vehicle.java public class Vehicle {    private String manufacturer;    private int seat;    private String drivetrain;    private float enginesize;    private float weight; //create getters for the attributes    public String getmanufacturer() {        return manufacturer;    }    public String getdrivetrain() {        return drivetrain;...

  • In the class GraphAlgorithm, insert java code for the method prim public class MyGraph { public...

    In the class GraphAlgorithm, insert java code for the method prim public class MyGraph { public static final int MAXSIZE = 100; public static final double BIGM = 10000000; public MyGraph(int size) { n = size; nodeStart = new Edge[MAXSIZE]; for (int i=0; i<n; i++) { nodeStart[i] = null; } } public int getSize() { return n; } public double getCost(int i, int j) { double value = BIGM; Edge e = nodeStart[i]; while (e !=null) { if (e.dest ==...

  • Using the following Java Class.... public class MicroWave { // Represent possible microwave heat selections private...

    Using the following Java Class.... public class MicroWave { // Represent possible microwave heat selections private final int LOW = 1; private final int MEDIUM = 2; private final int HIGH = 3;    // specifies the microwave heat selection(default is MEDIUM) private int heatSelection;    // specifies whether the microwave is on private boolean on;    private String color;    public MicroWave(int heatSelection, boolean on, String color) { this.heatSelection = heatSelection; this.on = on; this.color = color; }   ...

  • I have a little problem about my code. when i'm working on "toString method" in "Course"...

    I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student {    private String firstName;    private String lastName;    private String id;    private boolean tuitionPaid;       public Student(String firstName, String lastName, String id, boolean tuitionPaid)    {        this.firstName=firstName;        this.lastName=lastName;        this.id=id;        this.tuitionPaid=tuitionPaid;    }   ...

  • Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring;...

    Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring; public Person() {    this.numOffspring = 0; } public Person (int numOffspring) {    this.numOffspring = numOffspring; } public Person(String name, int birthYear, double weight, double height, char gender, int numCarryOn, int numOffspring) {    super(name, birthYear, weight, height, gender, numCarryOn);       if(numOffspring < 0) {        this.numOffspring = 0;    }    this.numOffspring = numOffspring; } public int getNumOffspring() {   ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT