



Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!




EXAMEN ESCRITO DEL SEGUNDO CUATRIMESTRE. 8 de junio de 2015. SOLUCIONES (^) Versión: 0 .0. 9
public LibroImpl(String s) { String[] sp = s.split("#"); if (sp.length != 5) { throw new IllegalArgumentException("Cadena con formato no válido"); } Integer numeroPaginas = new Integer(sp[3].trim()); checkNumeroPaginas(numeroPaginas); this .codigo = sp[0].trim(); this .titulo = sp[1].trim(); this .autor = sp[2].trim(); this .numeroPaginas = numeroPaginas; this .tipoPrestamo = TipoPrestamo. valueOf (sp[4].trim()); this .generos = new HashSet
private static Map<String, Libro> codigosLibros = new HashMap<String, Libro>(); public static Integer getNumLibrosCreados() { return codigosLibros .size(); } public static Set
EXAMEN ESCRITO DEL SEGUNDO CUATRIMESTRE. 8 de junio de 2015. SOLUCIONES (^) Versión: 0 .0. 9
public Vuelo vueloMasPasajerosAnyo(Integer anyo) { Vuelo v = null ; Comparator
public Vuelo vueloMasPasajerosAnyo2(Integer anyo) { Vuelo v = null ; Comparator
public Boolean todosVuelosDestinoMismaFecha(String destino) { return getVuelos().stream() .filter(x -> x.getDestino().equals(destino)) .allMatch(x->x.getFechaSalida().equals(x.getFechaLlegada())); }
public Long numeroPasajerosConMaletaFacturada(LocalDate fecha) { return getVuelos().stream() .filter(v->v.getFechaLlegada().equals(fecha)) .flatMap(v->v.getPasajeros().stream()) .filter(p->p.getMaletaFacturada().equals( true )) .count();
EXAMEN ESCRITO DEL SEGUNDO CUATRIMESTRE. 8 de junio de 2015. SOLUCIONES (^) Versión: 0 .0. 9
public SortedMap<String, Vuelo> vueloConMasPasajerosPorDestino() { SortedMap<String, Vuelo> aux = getVuelos().stream().collect( Collectors. groupingBy ( Vuelo::getDestino(), TreeMap::new, Collectors.maxBy( Comparator.comparingInt(v -> v.getPasajeros().size()))); return res; }
public SortedMap<String, Vuelo> vueloConMasPasajerosPorDestino() { SortedMap<String, Vuelo> res = new TreeMap<String, Vuelo>(); Map<String, Vuelo> aux = getVuelos().stream().collect( Collectors. groupingBy ( Vuelo::getDestino(), Collectors.maxBy( Comparator.comparingInt(v -> v.getPasajeros().size()))); res.putAll(aux); return res; }
#define MAXCAR 256 #define MAXVIDEOS 100 typedef char Cadena[MAXCAR]; typedef enum { AVI , MKV , WEBM } Formato; typedef struct { Cadena nombre; double tamano; Formato formato; } Video; typedef Video* PVideo; typedef Video ArrayVideos[MAXVIDEOS];
int leeVideoTeclado (PVideo res) { Cadena cadformato; int rformato, r=0; printf ("Nombre del vídeo: "); fflush (stdout); gets (res->nombre);
EXAMEN ESCRITO DEL SEGUNDO CUATRIMESTRE. 8 de junio de 2015. SOLUCIONES (^) Versión: 0 .0. 9 printf ("Tamaño: "); fflush (stdout); scanf ("%lf", &res->tamano); fflush (stdin); printf ("Formato: "); fflush (stdout); gets (cadformato); rformato = deCadenaAFormatoVideo(cadformato, &res->formato); if (rformato != 0 || !checkTamano(res->tamano)) { r = -1; } return r; } Logico checkTamano ( double tamano) { Logico res = CIERTO ; if (tamano <= 0) { res = FALSO ; } return res; } int deCadenaAFormatoVideo ( const Cadena formato, Formato *res) { int r = 0; if ( strcmp (formato, "AVI") == 0) { *res = AVI ; } else if ( strcmp (formato, "MKV") == 0) { *res = MKV ; } else if ( strcmp (formato, "WEBM") == 0) { *res = WEBM ; } else { r = -1; } return r; }
int deCadenaAFormatoVideo ( const Cadena formato, Formato *res) { int r = 0; if (! strcmp (formato, "AVI")) { *res = AVI ; } else if (! strcmp (formato, "MKV")) { *res = MKV ; } else if (! strcmp (formato, "WEBM")) { *res = WEBM ; } else { r = -1; } return r;