Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Aluno alunosExistente(int matAluno) {
- Iterator<Aluno> itAluno = listaAluno.iterator();
- Aluno aluno;
- while (itAluno.hasNext()) {
- aluno = itAluno.next();
- if (aluno.getNumMat() == matAluno) {
- return aluno;
- }
- }
- return null;
- }
- static Livro livrosExistente(int codLivro) {
- Iterator<Livro> itLista = listaLivro.iterator();
- Livro livro;
- while (itLista.hasNext()) {
- livro = itLista.next();
- if (livro.getCodigoLivro() == codLivro) {
- return livro;
- }
- }
- return null;
- }
- static void emprestarLivro() {
- Keyboard.clrscr();
- char resp;
- do {
- int matAlun = Keyboard.readInt("Digite a matricula do aluno: ");
- Aluno aluno = alunosExistente(matAlun);
- if (aluno == null) {
- System.out.println("Aluno não existe");
- } else {
- int codLivro = Keyboard.readInt("Digite Codigo do livro: ");
- Livro livro = livrosExistente(codLivro);
- if (livro == null) {
- System.out.println("Livro não existe");
- }
- livro = listaLivro.retrieve(livro);
- if(livro!= null){
- if(livro.getRefLivro() == null){
- aluno.inserirLivro(livro);
- livro.setComAluno(aluno);
- System.out.println("Emprestimo realizado!");
- }
- else{
- System.out.println("Livro ja emprestado!");
- }
- }
Add Comment
Please, Sign In to add comment