Software">
Nothing Special   »   [go: up one dir, main page]

Practica3 p60

Descargar como docx, pdf o txt
Descargar como docx, pdf o txt
Está en la página 1de 6

Guía de Práctica de aplicación y experimentación de los aprendizajes de la Universidad

Politécnica Salesiana
Carrera: CIENCIAS DE LA COMPUTACION
Nivel: 3ERO
Asignatura: PROGRAMACION APLICADA
Grupo: 1
Resultados de
Aprendizaje:
Indicador de logro:
Práctica Número: 3
Horas Dedicadas: 5
DESCRIPCIÓN DE LA PRÁCTICA:
Analice las clases creadas en la práctica e identifique cuales son los atributos y métodos, y construya el
diagrama de clases con sus correspondientes clases.
//Insertar el diagrama de clases

1.1 En base al diagrama de clases generado, construir la aplicación en Eclipse utilizando Herencia
CLASE: libro
private String ISBN;
private String autor;
private String nombreL;
private String year;

public libros() {

}
public libros(String ISBN_, String autor_, String nombreL_, String
year_) {
this.ISBN=ISBN_;
this.autor=autor_;
this.nombreL=nombreL_;
this.year=year_;
}

public String toString() {


return "ISBN: " + ISBN + "\nAutor del Libro: " + autor +
"\nNombre del Libro: " + nombreL + "\nAnio del libro:" + year;
}

public String getISBN() {


return ISBN;
}

public void setISBN(String iSBN) {


ISBN = iSBN;
}

public String getAutor() {


return autor;
}
public void setAutor(String autor) {
this.autor = autor;
}
public String getNombreL() {
return nombreL;
}
public void setNombreL(String nombreL) {
this.nombreL = nombreL;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
CLASE: biblioteca
private boolean estado;

private ArrayList<libros>lb;
Scanner leer=new Scanner(System.in);

public biblioteca() {
lb=new ArrayList<libros>();
}

public void Add(libros lib) {


lb.add(lib);
}
public void listar() {
for(libros libro: lb) {
System.out.println(libro.toString());
}
}

public void obtenerPrestamo(String isbn, boolean estado, String


solicitador) {
String aux, nom;
int op = -1;
aux = "";
do {
System.out.print("Ingrese el ISBN: ");
aux = leer.nextLine();
for (libros lib:lb) {
if (lib.getISBN().equals(aux) && estado == true) {
System.out.println("Libro Encontrado");
System.out.println("Libro Disponible");
System.out.println("Ingrese su nombre: ");
nom = leer.nextLine();
solicitador= nom;
estado= false;
op = 2;
System.out.println("Reservado con Exito");
break;
} else if (lib.getISBN().equals(aux) && estado == false) {
System.out.println("No Disponible");
System.out.println("Desea continuar \n 1) SI 2) NO");
op = Integer.parseInt(leer.nextLine());
break;
}

}
} while (op != 2);

public void devolver(String isbn) {


String codLib="";
System.out.println("Ingrese ISBN:
"); codLib = leer.nextLine();
for (int i = 0; i < isbn.length(); i++) {

if (isbn.equals(codLib) && estado== true) {


System.out.println("Este libro no esta disponible");
break;

} else if (isbn.equals(codLib) && estado == false) {


System.out.println("El libro a sido devuelto exitosamente");
estado= true;
break;
}
if (i == 99) {
System.out.println("Error el codigo no existe");
}
}
}

1.2 Generar una clase ejecutable que cumpla con los siguientes requisitos planteados en el problema:
Clase: ejecutable Capturas de Pantalla con cada opción ejecutada
public static void main(String[] args) {
// TODO Auto-generated
method stub
Scanner leer=new
Scanner(System.in);
libros lib= new libros();
biblioteca biblio=new
biblioteca();

String nombreL, ISBN=null,


autor, year, usuario;
int Lib_disp=0;
boolean estado;
int op;

while(true) {

System.out.println("*********
BIBLIOTECA CENTENARIO **********");

System.out.println("1) Ingresar un
libro");

System.out.println("2) Listar los


libros");

System.out.println("3) Prestar un
libro");

System.out.println("4) Devolver un
libro");

System.out.println("0) Salir");

System.out.println("Ingrese su
opcion: ");
op=leer.nextInt();

if(op==1) {

System.out.println("Ingrese el
ISBN: ");

ISBN=leer.next();
System.out.println("Ingrese el
autor:");

autor=leer.next();

System.out.println("Ingrese el
nombre del libro:");

nombreL=leer.next();

System.out.println("Ingrese el
anio: ");

year=leer.next();
biblio.Add(new
libros(ISBN, autor, nombreL, year));

System.out.println("OPERACION
EXITOSA :)");
Lib_disp++;
}
else if(op==2) {

System.out.println("LISTA DE
LIBROS DE LA BIBLIOTECA");

biblio.listar();

System.out.println("NUMERO TOTAL
DE LIBROS EN LA BIBLIOTECA:" + Lib_disp);

}
else if(op==3) {

System.out.println("PRESTAMO DE
LIBROS");

System.out.println("Ingrese el
ISBN: ");

ISBN=leer.next();

System.out.println("Ingrese el
nombre del libro:");

nombreL=leer.next();

System.out.println("Ingrese el
nombre del usuario a prestar el libro:");

usuario=leer.next();
estado=true;
biblio.obtenerPrestamo(ISBN,
estado, usuario);

System.out.println("NUMERO TOTAL
DE LIBROS PRESTADOS");
Lib_disp--;
}
else if(op==4) {

System.out.println("DEVOLUCION DE
LIBROS");

biblio.devolver(ISBN);
}
else if(op==0) {

System.out.println("Gracias pro
utilizar el programa :)");
break;
}
}
}

Problemas detectados durante el desarrollo de la práctica

También podría gustarte