Primer Commit
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,4 @@
|
||||
bin/
|
||||
.settings/
|
||||
.classpath
|
||||
.project
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Ficheros_04</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -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
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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<Pais> 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<Pais> obtnerPaisesPorCOntinente(String codigoContinente){
|
||||
IPaisDAO paisDAO = new PaisDaoFichero();
|
||||
List<Pais> 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();
|
||||
|
||||
|
||||
@@ -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<Pais> obtenerPaisesPorContinente(String codContinente);
|
||||
|
||||
}
|
||||
@@ -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<Pais> obtenerPaisesPorContinente(String codContinente) {
|
||||
|
||||
List<Pais> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 + "]";
|
||||
}
|
||||
}
|
||||
@@ -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 + "]";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user