Primer commit: aadd_fic02
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
# --- Directorios de compilación (binarios) ---
|
||||
bin/
|
||||
|
||||
# --- Archivos de configuración de Eclipse ---
|
||||
.metadata/
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# --- Archivos de configuración de VS Code ---
|
||||
.vscode/
|
||||
|
||||
# --- Archivos temporales y del sistema ---
|
||||
*.log
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
@@ -0,0 +1,21 @@
|
||||
-- Información de Paises
|
||||
# Se muestra información del código de continente, identificador de país, nombrel del país junto con su capital
|
||||
"01",1, "Angola", "Luanda"
|
||||
"02",62, "Brasil", "Brasilia"
|
||||
"02",63, "Canadá", "Ottawa"
|
||||
"02",64, "Chile", "Santiago De Chile"
|
||||
"02",65, "Colombia", "Bogotá"
|
||||
"03",92, "Afganistán", "Kabul"
|
||||
"03",93, "Arabia Saudita", "Riad"
|
||||
"03",105, "Filipinas", "Manila"
|
||||
"03",106, "India", "Nueva Delhi"
|
||||
"03",136, "Vietnam", "Hanoi"
|
||||
"04",147, "Bulgaria", "Sofía"
|
||||
"04",152, "España", "Madrid"
|
||||
"04",181, "Suecia", "Estocolmo"
|
||||
"04",182, "Suiza", "Berna"
|
||||
"05",185, "Australia", "Canberra"
|
||||
"05",186, "Fiyi", "Suva"
|
||||
"05",187, "Islas Marshall", "Majuro"
|
||||
"05",196, "Tonga", "Nuku'alofa"
|
||||
"05",197, "Tuvalu", "Funafuti"
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
module aadd_fic02 {
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.palomafp.aadd.jaec;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
File fichero = new File("C:\\Users\\alumnoT\\eclipse-workspace\\aadd\\fic02\\informacion_paises.txt");
|
||||
|
||||
String linea = "";
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(fichero))) {
|
||||
while ((linea = br.readLine()) != null) {
|
||||
if (linea.trim().charAt(0) != '#' && !(linea.trim().startsWith("--"))) {
|
||||
imprimirInformacionPaises(linea);
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
System.out.println(ioe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Metodos estaticos
|
||||
public static void imprimirInformacionPaises(String linea) {
|
||||
// Piden mostrar por pantalla
|
||||
// Pais [identificador=93, nombre=Arabia Saudita, capital=Riad,
|
||||
// continente=Continente [codigo=03, nombre=null]] INSERT INTO T_PAIS
|
||||
// (cod_continente, identificador, capital, nombre_pais) VALUES (93, '03',
|
||||
// 'Riad', 'Arabia Saudita');
|
||||
|
||||
// Ejemplo de la estructura de una linea de texto
|
||||
// "03",93, "Arabia Saudita", "Riad"
|
||||
|
||||
String[] informacion = linea.split(",");
|
||||
String codContinente = informacion[0].replace("\"", "").trim();
|
||||
String idPais = informacion[1].trim();
|
||||
String nombrePais = informacion[2].replace("\"", "").trim();
|
||||
String capitalPais = informacion[3].replace("\"", "").trim();
|
||||
|
||||
System.out.println("Pais [identificador=" + idPais + ", nombre=" + nombrePais + ", capital=" + capitalPais
|
||||
+ ", continente=Continente [codigo=" + codContinente + ", nombre=null]] "
|
||||
+ "INSERT INTO T_PAIS (cod_continente, identificador, capital, nombre_pais) VALUES (" + idPais + ", '"
|
||||
+ codContinente + "', '" + capitalPais + "', '" + nombrePais + "');");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.palomafp.aadd.jaec.vo;
|
||||
|
||||
public class Continente {
|
||||
private String codigo, nombre;
|
||||
|
||||
public Continente() {
|
||||
// Constructor vacio
|
||||
}
|
||||
|
||||
public Continente(String codigo, String nombre) {
|
||||
this.codigo = codigo;
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
// Getters y Setters
|
||||
public String getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
public void setCodigo(String codigo) {
|
||||
this.codigo = codigo;
|
||||
}
|
||||
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.palomafp.aadd.jaec.vo;
|
||||
|
||||
public class Pais {
|
||||
private int identificador;
|
||||
private String nombre, capital;
|
||||
private Continente continente;
|
||||
|
||||
public Pais() {
|
||||
// Constructor vacio
|
||||
}
|
||||
|
||||
public Pais(int identificador, String nombre, String capital, Continente continente) {
|
||||
this.identificador = identificador;
|
||||
this.nombre = nombre;
|
||||
this.capital = capital;
|
||||
this.continente = continente;
|
||||
}
|
||||
|
||||
|
||||
// Getters y Setters
|
||||
public int getIdentificador() {
|
||||
return identificador;
|
||||
}
|
||||
|
||||
public void setIdentificador(int identificador) {
|
||||
this.identificador = identificador;
|
||||
}
|
||||
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
public String getCapital() {
|
||||
return capital;
|
||||
}
|
||||
|
||||
public void setCapital(String capital) {
|
||||
this.capital = capital;
|
||||
}
|
||||
|
||||
public Continente getContinente() {
|
||||
return continente;
|
||||
}
|
||||
|
||||
public void setContinente(Continente continente) {
|
||||
this.continente = continente;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user