-
Notifications
You must be signed in to change notification settings - Fork 1
/
Funcionario.java
39 lines (29 loc) · 938 Bytes
/
Funcionario.java
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
36
37
38
39
public class Funcionario extends Pessoa {
private int matricula;
private float salario;
private String cargo;
public Funcionario(String nome, long cpf, int matricula) {
/* A primeira linha de qualquer construtor PRECISA SER
uma chamada ao construtor da superclasse, via super(.....).
Se nós não fizermos explicitamente essa chamada,
o compilador vai acrescentar automaticamente
a chamada
super();
*/
super(nome, cpf);
this.matricula = matricula;
this.cargo = "sem cargo";
this.salario = 1000f;
}
public int getMatricula() {
return matricula;
}
public void receberAumento(float percentual) {
salario *= (1 + percentual/100);
}
@Override
public String toString() {
return String.format("%d --- %s",
matricula, super.toString());
}
}