-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHospede.java
More file actions
40 lines (33 loc) · 1.26 KB
/
Hospede.java
File metadata and controls
40 lines (33 loc) · 1.26 KB
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
40
// * Classe Hospede - Demonstra:
// * 1. HERANÇA: Estende a classe abstrata Pessoa
// * 2. POLIMORFISMO DE SOBRESCRITA: Implementa exibirInformacoes() da superclasse
// * 3. ENCAPSULAMENTO: Atributo email privado com getter/setter
// * 4. CONSTRUTORES ENCADEADOS: Usa super() para chamar construtor da classe pai
// * 5. POLIMORFISMO DE SOBRESCRITA: Sobrescreve toString() para representação específica
public class Hospede extends Pessoa {
private String email;
public Hospede(String nome, String cpf, String telefone, String email) {
super(nome, cpf, telefone);
this.email = email;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
// Sobrescrevendo o método abstrato da classe Pessoa
@Override
public void exibirInformacoes() {
System.out.println("Hóspede:");
System.out.println("Nome: " + getNome());
System.out.println("CPF: " + getCpf());
System.out.println("Telefone: " + getTelefone());
System.out.println("Email: " + getEmail());
System.out.println("------------------------------");
}
@Override
public String toString() {
return getNome() + " - " + getEmail();
}
}