-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBiblioteca.java
More file actions
91 lines (79 loc) · 2.63 KB
/
Biblioteca.java
File metadata and controls
91 lines (79 loc) · 2.63 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package logicadenegocios;
import java.util.*;
public class Biblioteca{
private String nombre = null;
private ArrayList<Cliente> clientes;
private ArrayList<Libro> libros;
private ArrayList<Autor> autores;
public Biblioteca(String pNombre){
nombre=pNombre;
clientes = new ArrayList<Cliente>();
libros = new ArrayList<Libro>();
autores = new ArrayList<Autor>();
}
public void registrarLibro(String libroNombre,int libroIdentificador,int autorIdentificador,String autorNombre){
Autor autor = new Autor(autorIdentificador,autorNombre);
Libro libro=new Libro(libroNombre,libroIdentificador,autor);
libros.add(libro);
}
public void registrarAutor(int autorIdentificador,String autorNombre){
Autor autor= new Autor(autorIdentificador,autorNombre);
autores.add(autor);
}
public void registrarCliente(String pIdentificador ){
Cliente cliente = new Cliente();
}
public void prestarLibro(int pIdentificadorCliente,int pIdentificadorLibro){
if(validarCliente(pIdentificadorCliente)){
if(validarLibro(pIdentificadorLibro)){
Libro libro =buscarLibro(pIdentificadorLibro);
Cliente cliente=buscarCliente(pIdentificadorCliente);
cliente.registrarNuevoPrestamo(libro);
}else{
throw new BookNotFoundException(pIdentificadorCliente);
}
}else{
throw new ClientNotFoundException(pIdentificadorCliente);
}
}
public Libro buscarLibro(int pIdentificador){
for(int indice=0;indice<libros.size();indice++){
if(pIdentificador==libros.get(i).getIdentificador()){
return libros.get(i);
}
}
throw new BookNotFoundException(pIdentificador);
}
public boolean validarLibro(int pIdentificador){
for(int indice=0;indice<libros.size();indice++){
if(pIdentificador==libros.get(i).getIdentificador()){
return true;
}
}
return false;
}
public Cliente buscarCliente(int pIdentificador){
for(int indice=0;indice<clientes.size();indice++){
if(pIdentificador==clientes.get(i).getCedula()){
return clientes.get(i);
}
}
throw new ClientNotFoundException(pIdentificador);
}
public boolean validarCliente(int pIdentificador){
for(int indice=0;indice<clientes.size();indice++){
if(pIdentificador==clientes.get(i).getCedula()){
return true;
}
}
return false;
}
public Autor buscarAutor(int pIdentificador){
for(int indice=0;indice<autores.size();indice++){
if(pIdentificador==autores.get(i).getCedula()){
return autores.get(i);
}
}
throw new AutorNotFoundException(pIdentificador);
}
}