Crear un proyecto titulado Registro que nos permita ingresar la siguiente información: título, autor (usa la clase Autor), ISBN, páginas, edición, editorial, lugar (usa la clase Libro) y fecha de edición (usa la clase Fecha). La clase debe proporcionar los siguientes servicios: accedentes y mutadores, método para leer la información y método para mostrar la información. Este último método mostrará la información del libro con este formato:
Título: Introduction to Java Programming
3a. edición
Autor: Liang, Y. Daniel
ISBN: 0-13-031997-X
Prentice-Hall, New Jersey (USA), viernes 16 de noviembre de 2001
784 páginas
Lo información deberá ser almacenada en un arreglo.
Captura de muestra:
Clase Principal Registro:
package registro;
//@author Oliver
//http://blog2000.blogspot.mx/
import java.io.*;
import javax.swing.*;
import registro.Autor;
import registro.Fecha;
import registro.Libro;
public class Registro {
public static void main(String[] args)throws IOException {
//Declaracion de variables
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Autor autor1[] = new Autor[2];
Libro libro1[] = new Libro[6];
Fecha fecha1[] = new Fecha[3];
int opc,x=0,y=0,z=0;
int i,j,k;
//Menu
do{
//Pequeño menu de seleccion
opc=Integer.parseInt(JOptionPane.showInputDialog(null,""
+ "<html><p style="width: 600px; background-color: #CCCCCC; border-left: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 30px;"><b><img src='file:autor.png'/>1.Ingresar datos del autor.n"
+ "<html><p style="width: 600px; background-color: #CCCCCC; border-left: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 30px;"><b><img src='file:libro.png'/>2.Ingresar datos del libro.n"
+ "<html><p style="width: 600px; background-color: #CCCCCC; border-left: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 30px;"><b><img src='file:fecha.png'/>3.Ingresar fecha.n"
+ "<html><p style="width: 600px; background-color: #CCCCCC; border-left: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 30px;"><b><img src='file:visualizar.png'/>4.Vizualisar.n"
+ "<html><p style="width: 600px; background-color: #CCCCCC; border-left: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 30px;"><b><img src='file:salir.png'/>5.Salir. ","ELIGE UNA OPCION",JOptionPane.PLAIN_MESSAGE));
switch(opc){
case 1:
//Crea un objeto de tipo autor
autor1[x]= new Autor();
autor1[x].AsignarAutor();
x++;
break;
case 2:
//Crea un objeto de tipo libro
libro1[y] = new Libro();
libro1[y].AsignarLibro();
y++;
break;
case 3:
//Crea un objeto de tipo fecha
fecha1[z] = new Fecha();
fecha1[z].Asignarfecha();
z++;
break;
case 4:
//Metodo para vizualisar
for(i = 0;i < x;i++){
for(j = 0;j < y;j++){
for(k = 0;k < z;k++){
Icon icono1 = new ImageIcon("information.png");
JOptionPane.showMessageDialog(null,"<html><p style="background-color: #CCCCCC; width: 400px; padding: 10px; font-family: consolas; font-size: 20px;"><b>Titulo: "+libro1[j].getTitulo()+"n<html><p style="background-color: #CCCCCC; width: 400px; padding: 10px; font-family: consolas; font-size: 20px;"><b>Edicion: "+libro1[j].getEdicion()+"n<html><p style="background-color: #CCCCCC; width: 400px; padding: 10px; font-family: consolas; font-size: 20px;"><b>Autor: "+autor1[i].getNombre()+" "+autor1[i].getApellido()+"n<html><p style="background-color: #CCCCCC; width: 400px; padding: 10px; font-family: consolas; font-size: 20px;"><b>ISBN: "+libro1[j].getISBN()+"n<html><p style="background-color: #CCCCCC; width: 400px; padding: 10px; font-family: consolas; font-size: 20px;"><b>Lugar: "+libro1[j].getLugar()+"n<html><p style="background-color: #CCCCCC; width: 400px; padding: 10px; font-family: consolas; font-size: 20px;"><b>Fecha: "+fecha1[k].getDia()+" de "+fecha1[k].getMes()+" del "+fecha1[k].getAño()+"n<html><p style="background-color: #CCCCCC; width: 400px; padding: 10px; font-family: consolas; font-size: 20px;"><b>Numero de paginas: "+libro1[j].getPaginas()+" paginas.","SALIDA",JOptionPane.INFORMATION_MESSAGE,icono1);
}
}
}
break;
case 5:
Icon icono2 = new ImageIcon("C:\Users\Ortuño\Documents\NetBeansProjects\Registro\information.png");
JOptionPane.showMessageDialog(null,"<html><p style="background-color: #CCCCCC; padding: 10px; font-family: consolas; font-size: 20px;"><b>Hasta pronto !","SALIDA",JOptionPane.INFORMATION_MESSAGE,icono2);
break;
default:
Icon icono3 = new ImageIcon("C:\Users\Ortuño\Documents\NetBeansProjects\Registro\error.png");
JOptionPane.showMessageDialog(null,"<html><p style="background-color: #CCCCCC; padding: 10px; font-family: consolas; font-size: 20px;"><b>Opcion incorrecta !","MENSAJE",JOptionPane.ERROR_MESSAGE,icono3);
break;
}
}while(opc !=5);
}
}
Clase Autor:
package registro;
//@author Oliver
//http://blog2000.blogspot.mx/
import java.io.*;
import javax.swing.*;
public class Autor {
String nombre,apellido;
public void AsignarAutor()throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
nombre = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el nombre del autor:","AUTOR",JOptionPane.PLAIN_MESSAGE);
apellido = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el apellido del autor:","AUTOR",JOptionPane.PLAIN_MESSAGE);
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
}
Clase Libro:
package registro;
//@author Oliver
//http://blog2000.blogspot.mx/
import java.io.*;
import javax.swing.*;
public class Libro {
String titulo;
String ISBN;
String paginas;
String edicion;
String editorial;
String lugar;
public void AsignarLibro()throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
titulo = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el titulo:","LIBRO",JOptionPane.PLAIN_MESSAGE);
ISBN = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el ISBN:","LIBRO",JOptionPane.PLAIN_MESSAGE);
paginas = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el numero de paginas:","LIBRO",JOptionPane.PLAIN_MESSAGE);
edicion = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce la edicion:","LIBRO",JOptionPane.PLAIN_MESSAGE);
editorial = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce la editorial:","LIBRO",JOptionPane.PLAIN_MESSAGE);
lugar = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el lugar:","LIBRO",JOptionPane.PLAIN_MESSAGE);
}
public String getISBN() {
return ISBN;
}
public void setISBN(String ISBN) {
this.ISBN = ISBN;
}
public String getEdicion() {
return edicion;
}
public void setEdicion(String edicion) {
this.edicion = edicion;
}
public String getEditorial() {
return editorial;
}
public void setEditorial(String editorial) {
this.editorial = editorial;
}
public String getLugar() {
return lugar;
}
public void setLugar(String lugar) {
this.lugar = lugar;
}
public String getPaginas() {
return paginas;
}
public void setPaginas(String paginas) {
this.paginas = paginas;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
}
Clase Fecha:
package registro;
//@author Oliver
//http://blog2000.blogspot.mx/
import java.io.*;
import javax.swing.*;
public class Fecha {
String dia,mes,año;
public void Asignarfecha()throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
dia = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el dia:","FECHA",JOptionPane.PLAIN_MESSAGE);
mes = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el mes:","FECHA",JOptionPane.PLAIN_MESSAGE);
año = JOptionPane.showInputDialog(null,"<html><p style="background-color: #CCCCCC; border-left: solid 20px #FF0000; border-right: solid 20px #FF0000; padding: 10px; font-family: consolas; font-size: 20px;"><b>Introduce el año:","FECHA",JOptionPane.PLAIN_MESSAGE);
}
public String getAño() {
return año;
}
public void setAño(String año) {
this.año = año;
}
public String getDia() {
return dia;
}
public void setDia(String dia) {
this.dia = dia;
}
public String getMes() {
return mes;
}
public void setMes(String mes) {
this.mes = mes;
}
}
Acerca de mi

Buscar en el blog
Lista de categorias
- CSS (14)
- Entretenimiento (4)
- HTML (18)
- Iconos (13)
- Inspiración (13)
- JAVA Interfaz (6)
- jQuery (3)
- Lo que NO encontré en Internet (1)
- Programas en C (69)
- Recursos Online (13)
- Trucos (6)
- Widgets (2)







