-
Notifications
You must be signed in to change notification settings - Fork 0
/
herencia
35 lines (33 loc) · 1.17 KB
/
herencia
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class Main {
public static void main(String[] args) {
Cliente cliente = new Cliente();
cliente.nombre = " Isabel";
System.out.println("Nombre:" + cliente.nombre);
cliente.edad = 30;
System.out.println("Edad:" + cliente.edad);
cliente.telefono = 2739589;
System.out.println("Telefono:" + cliente.telefono);
cliente.credito = 200000;
System.out.println("Importe credito aprovado en euros:" + cliente.credito);
Trabajador trabajador = new Trabajador();
trabajador.nombre = " Joanna ";
System.out.println("Nombre del trabajador:" + trabajador.nombre );
trabajador.edad = 40;
System.out.println("Edad:"+ trabajador.edad);
trabajador.telefono = 3598899;
System.out.println("Numero de telefono:" + trabajador.telefono );
trabajador.salario = 40000;
System.out.println("Salario anual en euros:" + trabajador.salario);
}
}
class Persona {
String nombre;
int edad;
int telefono;
}
class Cliente extends Persona {
double credito;
}
class Trabajador extends Persona {
double salario;
}