commit 31df3711893a9208acb0063b9f98aca2649a3f2a Author: SASI Date: Thu Oct 1 00:28:20 2026 +0200 Primer Commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..efedf92 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.ginignore b/.ginignore new file mode 100644 index 0000000..43e6c06 --- /dev/null +++ b/.ginignore @@ -0,0 +1,4 @@ +bin/ +.settings/ +.classpath +.project \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..f865c31 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Ficheros_04 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3124684 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=25 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=25 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=25 diff --git a/bin/org/palomafp/aadd/ss/GestorMapaMundi.class b/bin/org/palomafp/aadd/ss/GestorMapaMundi.class new file mode 100644 index 0000000..93ed286 Binary files /dev/null and b/bin/org/palomafp/aadd/ss/GestorMapaMundi.class differ diff --git a/bin/org/palomafp/aadd/ss/dao/IPaisDAO.class b/bin/org/palomafp/aadd/ss/dao/IPaisDAO.class new file mode 100644 index 0000000..6942f69 Binary files /dev/null and b/bin/org/palomafp/aadd/ss/dao/IPaisDAO.class differ diff --git a/bin/org/palomafp/aadd/ss/dao/impl/PaisDaoFichero.class b/bin/org/palomafp/aadd/ss/dao/impl/PaisDaoFichero.class new file mode 100644 index 0000000..ca29517 Binary files /dev/null and b/bin/org/palomafp/aadd/ss/dao/impl/PaisDaoFichero.class differ diff --git a/bin/org/palomafp/aadd/ss/model/Continente.class b/bin/org/palomafp/aadd/ss/model/Continente.class new file mode 100644 index 0000000..de95d87 Binary files /dev/null and b/bin/org/palomafp/aadd/ss/model/Continente.class differ diff --git a/bin/org/palomafp/aadd/ss/model/Pais.class b/bin/org/palomafp/aadd/ss/model/Pais.class new file mode 100644 index 0000000..06a0be6 Binary files /dev/null and b/bin/org/palomafp/aadd/ss/model/Pais.class differ diff --git a/src/org/palomafp/aadd/ss/GestorMapaMundi.java b/src/org/palomafp/aadd/ss/GestorMapaMundi.java new file mode 100644 index 0000000..684b762 --- /dev/null +++ b/src/org/palomafp/aadd/ss/GestorMapaMundi.java @@ -0,0 +1,72 @@ +package org.palomafp.aadd.ss; + + +import java.util.List; +import org.palomafp.aadd.ss.model.Pais; + +import org.palomafp.aadd.ss.dao.*; +import org.palomafp.aadd.ss.dao.impl.PaisDaoFichero; + +public class GestorMapaMundi { + + public static void main(String[] args) { + + Pais pais = obtenerPaisesPorIdentificador(105); + System.out.println("Paises enconrado:"); + System.out.println(pais); + + System.out.println("=================================================================================="); + + List listaPaises = obtnerPaisesPorCOntinente("04"); + System.out.println("Paises del continente 04: "); + + for(Pais p : listaPaises) { + System.out.println(p); + } + } + + + + public static Pais obtenerPaisesPorIdentificador(int identificador) { + + IPaisDAO paisDAO = new PaisDaoFichero(); + Pais pais = paisDAO.obtenerPaisPorIdentificador(identificador); + return pais; + } + + + + public static List obtnerPaisesPorCOntinente(String codigoContinente){ + IPaisDAO paisDAO = new PaisDaoFichero(); + List listaPaises = paisDAO.obtenerPaisesPorContinente(codigoContinente); + return listaPaises; + } +} + + + + + + + + + + + + + + +/** +System.out.println("Paises enconrado:"); +System.out.println(pais); + +System.out.println(); + +System.out.println("Paises del continente 04: "); + +for(Pais p : listaPaises) { + System.out.println(p); +}**/ +//Pais pais = new Pais(); + + diff --git a/src/org/palomafp/aadd/ss/dao/IPaisDAO.java b/src/org/palomafp/aadd/ss/dao/IPaisDAO.java new file mode 100644 index 0000000..f8399ea --- /dev/null +++ b/src/org/palomafp/aadd/ss/dao/IPaisDAO.java @@ -0,0 +1,12 @@ +package org.palomafp.aadd.ss.dao; + +import java.util.List; + +import org.palomafp.aadd.ss.model.Pais; + +public interface IPaisDAO { + + Pais obtenerPaisPorIdentificador(int idPais); + List obtenerPaisesPorContinente(String codContinente); + +} diff --git a/src/org/palomafp/aadd/ss/dao/impl/PaisDaoFichero.java b/src/org/palomafp/aadd/ss/dao/impl/PaisDaoFichero.java new file mode 100644 index 0000000..bd7a142 --- /dev/null +++ b/src/org/palomafp/aadd/ss/dao/impl/PaisDaoFichero.java @@ -0,0 +1,117 @@ +package org.palomafp.aadd.ss.dao.impl; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.palomafp.aadd.ss.dao.IPaisDAO; +import org.palomafp.aadd.ss.model.Pais; + +public class PaisDaoFichero implements IPaisDAO { + + + String ruta = "C:\\Users\\sajed\\Desktop\\2DAM\\AADD\\aadd\\fic03\\informacion_paises (2).txt"; + File paises = new File(ruta); + + @Override + public Pais obtenerPaisPorIdentificador(int idPais) { + + Pais pais = null; + try { + BufferedReader br = new BufferedReader(new FileReader(paises)); + String linea; + while((linea = br.readLine()) != null) { + + if((linea.isEmpty() || linea.startsWith("#"))) { + continue; + } + + linea = linea.replaceAll("\"","" ); + String[] datos = linea.split(","); + + String codigoContinente = datos[0].trim(); + int idpais = Integer.parseInt(datos[1].trim()); + String nombre = datos[2].trim(); + String capital = datos[3].trim(); + + if(idpais == idPais) { + pais = new Pais(); + + pais.setIdentificador(idPais); + pais.setNombre(nombre); + pais.setCapital(capital); + + break; + } + + + } + + + br.close(); + + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return pais; + + } + + + + + @Override + public List obtenerPaisesPorContinente(String codContinente) { + +List listaPaises = new ArrayList<>(); + + try { + BufferedReader br = new BufferedReader(new FileReader(paises)); + + String linea; + + while((linea = br.readLine()) != null) { + + if(linea.isEmpty() || linea.startsWith("#")) { + continue; + } + + linea = linea.replace("\"", ""); + + String[] datos = linea.split(","); + + String codigo = datos[0].trim(); + int identificador = Integer.parseInt(datos[1].trim()); + String nombre = datos[2].trim(); + String capital = datos[3].trim(); + + if(codigo.equals(codContinente)) { + Pais pais = new Pais(); + + pais.setIdentificador(identificador); + pais.setNombre(nombre); + pais.setCapital(capital); + + listaPaises.add(pais); + } + + } + + br.close(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return listaPaises; + } + +} diff --git a/src/org/palomafp/aadd/ss/model/Continente.java b/src/org/palomafp/aadd/ss/model/Continente.java new file mode 100644 index 0000000..c8625a0 --- /dev/null +++ b/src/org/palomafp/aadd/ss/model/Continente.java @@ -0,0 +1,32 @@ +package org.palomafp.aadd.ss.model; + +public class Continente { + + private String codigo; + private String nombre; + + public Continente() { + } + + 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; + } + + @Override + public String toString() { + return "Continente [codigo=" + codigo + + ", nombre=" + nombre + "]"; + } +} \ No newline at end of file diff --git a/src/org/palomafp/aadd/ss/model/Pais.java b/src/org/palomafp/aadd/ss/model/Pais.java new file mode 100644 index 0000000..a155c04 --- /dev/null +++ b/src/org/palomafp/aadd/ss/model/Pais.java @@ -0,0 +1,42 @@ +package org.palomafp.aadd.ss.model; + +public class Pais { + + private int identificador; + private String nombre; + private String capital; + + public Pais() { + } + + 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; + } + + @Override + public String toString() { + return "Pais [identificador=" + identificador + + ", nombre=" + nombre + + ", capital=" + capital + "]"; + } +} \ No newline at end of file