desenvolva o procedimento para remover um aluno de uma lista de alunos, a partir da matrícula!
No momento fiz até aqui, mas a parte de remover está me complicando
package pkg24do06;
import java.util.LinkedList;
import javax.swing.JOptionPane;
public class cadastro {
LinkedList<Aluno> turma = new LinkedList<>();
public static void main(String[] args) {
cadastro a = new cadastro();
a.cadastra();
}
public void cadastra() {
int qdt_alunos = Integer.parseInt(JOptionPane.showInputDialog("Quantos alunos deseja cadastrar?"));
for (int i = 0; i < qdt_alunos; i++) {
JOptionPane.showMessageDialog(null, "Ok! \n Agora vamos para os dados do " + (i + 1) + "º aluno(a)");
String nome = JOptionPane.showInputDialog("\n Nome do " + (i + 1) + "º aluno(a) a ser cadastrado");
int num_matricula = Integer.parseInt(JOptionPane.showInputDialog("Matricula do aluno(a) " + (i + 1) + ":"));
int idade = Integer.parseInt(JOptionPane.showInputDialog("Idade do " + (i + 1) + "º aluno(a):"));
JOptionPane.showMessageDialog(null, "Cadastro do Aluno \n Nome: " + nome + "\n Matricula: " + num_matricula + "\n Idade: " + idade);
turma.stream().filter((aluno) -> (num_matricula == aluno.num_matricula)).forEachOrdered((_item) -> {
JOptionPane.showMessageDialog(null, "Matricula já cadastrada!!");
});
turma.add(new Aluno(nome, num_matricula, idade));
}
}
}