id
stringlengths
36
36
text
stringlengths
1
1.25M
08926fcf-9080-4f60-803e-26a7fabfd543
public Cuenta(int numero, double saldo) { this.numero = numero; this.saldo = saldo; }
e65cc97d-7a45-45c6-8bf4-5c7045057718
public double getSaldo() { return saldo; }
28439f5b-05bd-4522-886b-173157a8dd7e
public int getNumero() { return numero; }
b4bfa4ac-a7a3-4941-80f7-e3019a0495f3
public synchronized void extraer(double monto) throws BancoException { if (this.saldo < monto){ throw new BancoException("Saldo induficiente"); } this.saldo -= monto; }
82c05429-1ef9-4e69-b61c-083e70d4ab14
public synchronized void depositar(double monto) { this.saldo += monto; }
92d345ce-fd51-4019-a512-cf1db6218814
public Banco() { this.cuentas.add(new Cuenta(100, 5000)); this.cuentas.add(new Cuenta(103, 15000)); this.cuentas.add(new Cuenta(104, 10000002)); this.cuentas.add(new Cuenta(105, 12)); }
f0b86224-7795-46e2-9d6d-151f2563f7f4
public Cuenta getCuenta(int numeroCuenta) throws BancoException { if (numeroCuenta <0){ throw new BancoException("Numero de cuenta no valido"); } for (Cuenta c: this.cuentas){ if (c.getNumero() == numeroCuenta) { return c; } } throw new BancoException("Cuanta inexistente"); }
bdeb4e0e-d7c0-425c-b844-6b202572aeae
public void debitar(List<Debito> debitos) { for (Debito debito: debitos){ try { debito.setCuenta(this.getCuenta(debito.getNumeroCuenta())); new Thread(debito).start(); } catch (BancoException e) { System.err.println("No existe la cuenta " + debito.getNumeroCuenta()); } } }
a5a1d3d0-b8d4-4805-8fa2-0e928db41281
public BancoException(String message) { super (message); }
8c48dc5b-e83f-440d-a179-713e59e6af77
public Cuenta getCuenta() { return cuenta; }
40bd3b61-7f34-484b-9766-f4da400495ad
public void setCuenta(Cuenta cuenta) { this.cuenta = cuenta; }
33f1a8f3-8205-4b68-9c30-27511c72faa8
public int getNumeroCuenta() { return numeroCuenta; }
4c844d80-7d48-4c75-9184-36f7d14c23a7
public double getMonto() { return monto; }
a8be1cdc-b9cb-4d48-899c-ce0046972842
public void setMonto(double monto) { this.monto = monto; }
700353ad-8984-4642-9f7f-6964510b5797
public void setNumeroCuenta(int numeroCuenta) { this.numeroCuenta = numeroCuenta; }
99133276-bfe1-4247-9bb4-b65527a59a6e
@Override public void run() { try { this.getCuenta().extraer(this.getMonto()); } catch (BancoException e) { e.printStackTrace(); } }
9f68394b-4cc6-4bad-81e5-6c34e0ff6ee0
static BañoQuimico getBaño(){ return baño; }
6a50e31b-f5db-40a4-939d-18f3af85485e
public synchronized void usar (FanDeLuisMiguel fan){ }
5167d36b-5d8e-4277-bfeb-c2bbcb02e0a4
public synchronized void limpiar (Empleado empleado){ }
89d61d96-eb8e-4a2b-9544-81ccc57eca51
@Override public void run() { gritar(); BañoQuimico.getBaño().usar(this); }
98b6f2d0-3030-41fc-8904-8e8018d074da
public void gritar(){ //Grita }
3f54013e-87ad-4202-a798-62b73cd4a04b
public static void main(String[] args) { for(int i = 0; i < 15; i++){ FanDeLuisMiguel fan = new FanDeLuisMiguel(); new Thread(fan).start(); } Empleado empleado = new Empleado(); empleado.start(); }
6093aa1e-ce5f-4b82-8309-ac003722cfa0
@Override public void run() { BañoQuimico baño = BañoQuimico.getBaño(); baño.limpiar(this); }
7ca6e71c-8f93-457b-ab53-68dc80ed1cd6
public void crearPersona (Persona persona) throws PersonaException { Connection cnn = null; try { cnn = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/bdprueba", "postgres", "postgres"); PreparedStatement pstmt = cnn.prepareStatement("Select nombre FROM persona WHERE documento = ?"); pstmt.setInt(1, persona.getNumeroDocumento()); ResultSet rs = pstmt.executeQuery(); if (rs.next()){ throw new PersonaException("La persona ya se encuentra registrada en la base de datos"); } rs.close(); pstmt.close(); pstmt = cnn.prepareStatement("INSERT INTO persona (documento, nombre, edad) VALUES (?, ?, ?)"); pstmt.setInt (1, persona.getNumeroDocumento()); pstmt.setString(2, persona.getNombre()); pstmt.setInt (3, persona.getEdad()); pstmt.executeUpdate(); pstmt.close(); } catch (SQLException e) { throw new PersonaException("Error de acceso a datos"); } finally { try { cnn.close(); } catch (SQLException e) { } } }
dfb613e4-aacf-4119-ab69-e7c8b64e6518
public int getNumeroDocumento() { return numeroDocumento; }
7b729c45-753f-4d4f-8b2e-df5f0a89fcf3
public String getNombre() { return nombre; }
950de1cf-a316-457a-8fe4-0528d0077f8c
public int getEdad() { return edad; }
36366c1e-f60b-4474-9cf4-b4108b83bc0a
public Persona(int numeroDocumento, String nombre, int edad) { this.numeroDocumento = numeroDocumento; this.nombre = nombre; this.edad = edad; }
d643372d-ec06-4279-9ed9-16ebcddba602
public static void main(String[] args) throws PersonaException { Persona persona = new Persona(17345123, "DIEGO MARADONA", 51); EjercicioJDBC accesoBD = new EjercicioJDBC(); accesoBD.crearPersona(persona); accesoBD.crearPersona(persona); }
03f51bde-2e6a-4350-8a5a-e7035f5b04a9
public PersonaException(String message) { super(message); }
5c3de943-6979-424f-8fb6-01391d97b995
@Override public void run() { Darsena.getDarsena().atracar(this); }
9b93289c-a6fd-483c-8c7d-1fb3c15757fd
public static Darsena getDarsena(){ return Darsena.darsena; }
884415f4-2fce-457e-ae30-a89f864f3882
public synchronized void atracar(Barco barco){ // La implementación del método no era // necesaria, bastaba con la declaración }
0f203311-6d46-41c2-be48-3e9b8adf05de
public static void main(String[] args) { for (int i= 0; i<= 5; i++){ new Thread(new Barco()).run(); } }
059161bf-0c8b-48bc-ae96-77befd23666d
public static List <String> procesar(String pathArchivo) throws Exception { List <String> resultado = new LinkedList<String>(); try { Reader reader = new FileReader(pathArchivo); BufferedReader br = new BufferedReader(reader); String s = null; int i = 1; while ((s = br.readLine()) != null){ if (i++ %2 == 0) { resultado.add(s.toLowerCase()); } else { resultado.add(s.toUpperCase()); } } br.close(); } catch (IOException ex) { throw new Exception("Error al leer el archivo"); } return resultado; }
f37d9e12-a583-44bc-96ba-572a6b71eb55
public static void main(String[] args) throws Exception { for (String s: PasaMayusculasMinusculas.procesar("prueba.txt")){ System.out.println(s); } }
8ecaa16d-e3a5-42e1-866f-cd2c0213c4b1
public static void main(String[] args) throws Exception { String origen = args[0]; String destino = args[1]; Reader reader = new FileReader(origen); Writer writer = new FileWriter(destino); BufferedReader br = new BufferedReader(reader); String s = null; while ((s = br.readLine()) != null){ s = s.replaceAll("ARRIBA", "ABAJO"); writer.write(s + "\n"); } br.close(); writer.close(); }
9d10b9b1-ceff-48d3-9af9-986375ec6637
public static void main(String[] args) throws IOException { File raizTmp = new File(args[0]); File carpeta1 = new File ( raizTmp, "aaa"); carpeta1.mkdir(); File archivo1 = new File ( carpeta1, "archivo" + 10 + ".txt"); archivo1.createNewFile(); Writer w = new FileWriter(archivo1); w.write("HOla gente!\n"); w.write("Vamo Croacia!\n"); w.close(); }
749d9f3e-777d-45d7-bb1f-597e850c2934
public static void VentasVendedor(Date fecha, String codigo) { try { Class.forName("org.postgres.Driver"); Connection cnn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/ventas", "postgres", "postgres"); PreparedStatement pstmt = cnn.prepareStatement( " SELECT artiuclo, importe, forma_pago " + " FROM venta " + " WHERE fecha = ? AND vendedor = ?"); pstmt.setDate(1, new java.sql.Date(fecha.getTime() )); pstmt.setString(2, codigo); ResultSet rs = pstmt.executeQuery(); while (rs.next()){ String s = rs.getString("articulo"); s += rs.getDouble("importe"); s += rs.getString("forma_pago"); System.out.println(s); } rs.close(); pstmt.close(); cnn.close(); } catch (Exception ex) { System.err.println("Error al acceder a los datos"); } }
8a7651a2-bbcd-444e-80e8-dfc9876d3bba
ArrayList<Escala> getEscalas() { return escalas; }
da6163f9-bc5b-4f48-b804-0de9c2d0a71c
void setEscalas(ArrayList<Escala> escalas) { this.escalas = escalas; }
4bd6d8ea-a37d-4016-b64e-15087838822b
ArrayList<Cancion> getCanciones() { return canciones; }
e8604ea8-c98e-41b6-94b3-8a4e0d707649
void setCanciones(ArrayList<Cancion> canciones) { this.canciones = canciones; }
6af3474e-8999-4f0a-b74b-a80c88a155a7
ArrayList<ListaReproduccion> getListasReproduccion() { return listasReproduccion; }
01b04b8b-97c8-4d3d-bc02-3e46a32f76cc
void setListasReproduccion(ArrayList<ListaReproduccion> listasReproduccion) { this.listasReproduccion = listasReproduccion; }
ceef5449-6dae-4b44-9ef3-4625f2469fcd
ArrayList<ListaInteligente> getListasInteligentes() { return listasInteligentes; }
df914f53-e68d-48cf-b653-0a83fef08e45
void setListasInteligentes(ArrayList<ListaInteligente> listasInteligentes) { this.listasInteligentes = listasInteligentes; }
ab6d3e32-ff46-4064-bd38-5312ac4ed577
public void inicializar(){ }
1aa707b6-5d43-4391-9027-cccb44868051
public void agregarArchivos(String carpeta){ System.out.println("Agregando archivos"); File dir = new File(carpeta); String[] children = dir.list(); canciones = new ArrayList<>(); Cancion c; if (children == null) { // Either dir does not exist or is not a directory } else { for (int i=0; i < children.length; i++) { // Get filename of file or directory String filename = children[i]; System.out.println(i+" "+filename); c= new Cancion(); c.setRutaArchivo(carpeta+filename); canciones.add(c); } } }
6f6f2ebf-bd85-4be6-8f11-270172424244
public Boolean crearListaReproduccion(String nombre, ArrayList<Cancion> canciones){ return null; }
924b6467-a10d-4858-a602-5f3a01be67ff
public Boolean crearListaInteligente(String nombre, ArrayList<Cancion> canciones){ return null; }
386fe177-8eca-49ff-abaf-26310bbc37d5
public ArrayList<Cancion> ordenarCancionesPor(String parametro, Boolean ascendente){ return null; }
246883e6-118a-4125-8ffb-9fe37479c092
public ArrayList<Cancion> filtrarCancionesPor(ArrayList<Criterio>criterios){ return null; }
89e11ddf-1bbb-4f27-b942-a41999c63fbe
public Boolean eliminarLista(String nombre){ return null; }
f98846a5-859e-4eb9-aab3-781e4a11cb45
public Boolean editarMetadatos(Integer xx, String nombre){ return null; }
6ac28960-5275-4a8f-a20a-38f8762e1567
public ListaReproduccion darMezclaArmonizada(String xx){ return null; }
f35fd030-5abe-4eeb-a7ab-49989f729cfc
public void reproducirCancion(int i) { if(canciones.size()>i){ Sequence mySeq; Sequencer sequencer; String ruta = canciones.get(i).getRutaArchivo(); try { sequencer = MidiSystem.getSequencer(); if (sequencer != null){ sequencer.open(); FileInputStream is = new FileInputStream(ruta); mySeq = MidiSystem.getSequence(is); sequencer.setSequence(mySeq); System.out.println("Reproducción de "+ruta); sequencer.start(); } } catch (MidiUnavailableException | InvalidMidiDataException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
c687dc2d-3589-45b6-bea7-531189c86bf2
public Integer getValor() { return valor; }
c45505eb-615e-41d2-8838-a4766c9a770f
public void setValor(Integer valor) { this.valor = valor; }
a840bf07-7e8e-4180-a384-9dead244873b
public String getNombre() { return nombre; }
e98af4be-d157-4ccb-bb1b-3915ac40da99
public void setNombre(String nombre) { this.nombre = nombre; }
8004bf0c-8001-4e89-b3a7-377c90207ba9
public String getNombre() { return nombre; }
b5773419-7c34-4ccd-b382-26cad2c4e653
public void setNombre(String nombre) { this.nombre = nombre; }
3202b755-b149-488a-b026-6e2e3463e0d8
public ArrayList<Nota> getNotasEscala() { return notasEscala; }
9c57058d-57f2-4578-bbbe-f8841bc84aa9
public void setNotasEscala(ArrayList<Nota> notasEscala) { this.notasEscala = notasEscala; }
81d834b4-67d6-4c7d-909e-75279578e992
public Integer getInstrumento() { return instrumento; }
fcd3a947-e754-4f9f-9ba2-80902a9eea41
public void setInstrumento(Integer instrumento) { this.instrumento = instrumento; }
5d44666d-7f34-4979-ad54-6915265f307f
public ArrayList<Nota> getNotas() { return notas; }
cfcc8f78-2d8f-45df-886a-3a7c75b32f4e
public void setNotas(ArrayList<Nota> notas) { this.notas = notas; }
ac386ace-4531-433f-8d43-d8e3e9e99712
public static void main(String[] args) { LibreriaMusical lm = new LibreriaMusical(); //Archivos descargados de http://midi-archive.com/ lm.agregarArchivos("files/data/midis/"); lm.reproducirCancion(0); }
09bab9a2-de81-4653-8fe7-1486ad85dd0b
String getNombre() { return nombre; }
c6029975-629a-41d4-aac5-657d33decb92
void setNombre(String nombre) { this.nombre = nombre; }
96753a14-ebbb-4c76-9739-a2fc192135aa
ArrayList<Cancion> getCanciones() { return canciones; }
6e25fcde-2077-4a16-9c09-8a4855aa804c
void setCanciones(ArrayList<Cancion> canciones) { this.canciones = canciones; }
50356cd5-cbc8-4dd2-9983-bc8191b8a19d
String getCampo() { return campo; }
5f3f91e1-01b5-40ba-94ee-190f3a37324e
void setCampo(String campo) { this.campo = campo; }
db5fef9b-c989-4995-a5e9-79a06d9ed6e9
Integer getValor() { return valor; }
f82601dd-6de8-4a87-94cd-9902e17c489f
void setValor(Integer valor) { this.valor = valor; }
2574e216-b1ca-4c78-bc79-345c3f3167ab
Boolean getIncluido() { return incluido; }
cd12a8e2-b4ce-4fb0-9b57-d3f30150f1d6
void setIncluido(Boolean incluido) { this.incluido = incluido; }
b2695c10-a557-4763-abd3-e2147f7015f1
public Escala calcularEscalaCancion(){ return null; }
69d837e1-8f60-4ae6-bc90-06126a82be33
Integer getIdentificador() { return identificador; }
c7d56673-b419-42f5-8b8b-c6863f08124a
void setIdentificador(Integer identificador) { this.identificador = identificador; }
fee1376a-ba1e-4501-bdde-e7556061fc24
String getTitulo() { return titulo; }
a755c54c-6fcb-48f1-9337-80b87e815b57
void setTitulo(String titulo) { this.titulo = titulo; }
8e192d97-1a41-4a7d-94aa-5eef4dfe6467
String getArtista() { return artista; }
4b53e270-ce6b-49ac-8a10-5705ecd06bcb
void setArtista(String artista) { this.artista = artista; }
8642ef05-f281-4ddf-b360-049dc65c13e2
Integer getAnho() { return anho; }
f0a2838b-a8d3-4a42-a246-a172f8f8733e
void setAnho(Integer anho) { this.anho = anho; }
06f83db1-60c4-4021-a906-f8e1170f1963
String getCasaDiscografica() { return casaDiscografica; }
b08709b3-1477-499a-a1ac-f03c94163608
void setCasaDiscografica(String casaDiscografica) { this.casaDiscografica = casaDiscografica; }
b48981a3-2518-412c-b613-282fd6fc6d2d
String getComentarios() { return comentarios; }
305bf94e-62cb-4392-a3ab-3752b80a7edc
void setComentarios(String comentarios) { this.comentarios = comentarios; }
c49acd8e-3901-4b72-ae06-d6077e81900a
Long getDuracion() { return duracion; }
cebe495e-c0c3-413a-9495-f1364e80e25b
void setDuracion(Long duracion) { this.duracion = duracion; }
97878097-4d97-4d6b-8872-f39dd2e36559
String getRutaArchivo() { return rutaArchivo; }
94fcf937-24d1-463f-ab0f-c4b314c8fb44
void setRutaArchivo(String rutaArchivo) { this.rutaArchivo = rutaArchivo; }
f3a7cc53-3468-4a27-b3b4-94ed86613b08
ArrayList<Pista> getPistas() { return pistas; }
8b4de972-deb2-487a-9ed2-0dc3b352adbb
void setPistas(ArrayList<Pista> pistas) { this.pistas = pistas; }
2b0e2b10-7577-424c-be10-92f7ffc2fc96
String getNombre() { return nombre; }