-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurso.java
64 lines (49 loc) · 1.39 KB
/
Curso.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package gustavohoresteesantosbarros_atividadeavaliativa2;
/**
*
* @author gustavohorestee
*/
import java.util.ArrayList;
import java.util.List;
public class Curso {
private String nome;
private List<Professor> professores;
private List<Aluno> alunos;
public Curso(String nome) {
this.nome = nome;
this.professores = new ArrayList<>();
this.alunos = new ArrayList<>();
}
public String getNome() {
return nome;
}
public List<Professor> getProfessores() {
return professores;
}
public List<Aluno> getAlunos() {
return alunos;
}
public void addProfessor(Professor professor) {
if (!professores.contains(professor)) {
professores.add(professor);
professor.addCurso(this);
}
}
public void addAluno(Aluno aluno) {
alunos.add(aluno);
aluno.setCurso(this);
}
public void imprimirCurso() {
System.out.println("Curso: " + nome);
if (!professores.isEmpty()) {
System.out.println("Professores: ");
for (Professor professor : professores) {
System.out.println(professor.getTitulacao() + " " + professor.getSalario());
}
}
}
}