Someone could tell me that exactly the reserved word super is used in this exercise (it is used to call the constructor of the parent class) but I do not understand why the argument String nom in the parent class is defined as this class abstract and can not be instantiated ... I'm starting in Java following the course of informational pills in case they wonder what I do and I do not know how to xD, Thanks in advance!
package poo;
import java.util.Date;
import java.util.GregorianCalendar;
public class Uso_Persona {
public static void main(String[] args) {
// TODO Auto-generated method stub
Persona[] laspersonas=new Persona[2];
laspersonas[0]=new Empleado2("Luis Conde",50000,2009,02,25);
laspersonas[1]=new Alumno("Ana Lopez","Biologicas");
for(Persona p: laspersonas){
System.out.println(p.damenombre()+", "+p.damedescripcion());
}
}
}
abstract class Persona{
private String nombre;
public abstract String damedescripcion();
public Persona(String nom) {
nombre=nom;
}
public String damenombre() {
return nombre;
}
}
class Empleado2 extends Persona{
public Empleado2(String nom,double sue,int agno,int mes,int dia) {
super(nom);
sueldo=sue;
GregorianCalendar calendario=new GregorianCalendar(agno,mes -1,dia);
altaContrato=calendario.getTime();
id=idsiguiente;
idsiguiente++;
}
public String damedescripcion() {
return"Este empleado tiene un id="+id+" con un sueldo="+ sueldo;
}
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;
}
private double sueldo;
private Date altaContrato;
private int id;
private static int idsiguiente=1;
}
class Alumno extends Persona{
private String carrera;
public Alumno(String nom,String car) {
super(nom);
carrera=car;
}
public String damedescripcion(){
return"Este alumno esta estudiando la carrera de="+carrera;
}
}