Download Examen Ordinario 0910
Document related concepts
no text concepts found
Transcript
ALUMNO : ___________________________________________________________________________ DIIN Asignatura: “LS1118” 2º 1INM1 Cuatrimestre: Grupo: “Fundamentos de la informática” Examen: Curso: Final 2009/2010 Convocatoria: Ordinaria Fecha: 28/05/2010 1. Se desea crear un conjunto de clases para representar en un programa las personas pertenecientes a la Universidad. Existen tres tipos de universitarios: alumnos, profesores, y personal de administración y servicios (PAS). Los dos últimos son empleados de la Universidad (los alumnos no). a. Se pide hacer el diseño arquitectónico detalladamente de una jerarquía de clases que representen a estas personas, teniendo en cuenta los siguientes datos (todos de tipo texto) y operaciones: • • • • • Todos los universitarios tienen nombre y dirección, y operación para mostrar datos Los alumnos tienen centro y operación para matricularse en un centro Los profesores tienen departamento y operación para adscribirse a él Los PAS tienen unidad administrativa y operación para adscribirse a ella Los empleados tienen número de registro y operación para obtenerlo b. Se pide también el diseño detallado de los constructores de cada clase, a los que se pasarán como parámetros los valores iniciales de cada atributo. 2 puntos 2. Escribir en Java la implementación de los métodos: i. public void escribeMatrizEnFichero(double[][] m, String nomFich) El método debe servir para escribir matrices de cualquier dimensión, se deja a elección del alumno la forma en que se almacenan las dimensiones de la matriz en el fichero. 2 puntos 3. Implemente una clase que declare e inicialice un array e implemente un método que realice una búsqueda binaria de una clave en dicho array: i. De forma iterativa ii. De forma recursiva 2 puntos ALUMNO : ___________________________________________________________________________ 4. Escribir una clase llamada Matriz, en el fichero Matriz.java, que implemente las estructuras de datos y métodos necesarios para manejar matrices cuadradas de números enteros, cuya capacidad puede definir el usuario. a. Debe incluir los siguientes métodos: • void asignarDatos(int[] vector), rellena el contenido de la matriz por filas con los datos pasados desde un vector unidimensional. • void suma(Matriz m), suma los valores de la propia clase con los valores de una matriz pasada como argumento. • void producto(Matriz m), multiplica los valores de la propia clase con los valores de una matriz pasada como argumento. • void traspuesta(), calcula la traspuesta de la matriz. • void mostrar(), muestra el contenido de la matriz. b. Escribir un programa Java orientado a objetos, llamado MainMatriz.java, que realice las siguientes operaciones: • • • • • • • Crear dos matrices de tamaño 3x3. Rellenar la primera con los datos: 3, 2, 1, 1, 2, 3, 2, 3, 1. Rellenar la segunda con los datos: 1, 1, 2, 2, 1, 1, 1, 2, 1. Mostrar el contenido de ambas matrices. Multiplicar la primera por la segunda y mostrar el resultado. Sumar la primera por la segunda y mostrar el resultado. Calcular la traspuesta de la primera matriz y mostrar el resultado. 2,5 puntos 5. Escribir en Java la implementación del método inserta() de la clase siguiente: /** * Clase que representa una lista de nombres */ public class ListaNombres { // atributo, que contiene la lista private LinkedList<String> lista=new LinkedList<String>(); /** * Inserta sin repeticiones los strings del array nombres * en la lista, añadiéndolos uno por uno al final. Aquellos que * ya están en la lista no se añaden. */ public void inserta(String[] nombres) {... } } 1,5 puntos ALUMNO : ___________________________________________________________________________ Class LinkedList Method Summary boolean void add(E o) Appends the specified element to the end of this list. add(int index, E element) Inserts the specified element at the specified position in this list. boolean addAll(Collection<? extends E> c) Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. boolean addAll(int index, Collection<? extends E> c) Inserts all of the elements in the specified collection into this list, starting at the specified position. void addFirst(E o) Inserts the given element at the beginning of this list. void addLast(E o) Appends the given element to the end of this list. void clear() Removes all of the elements from this list. Object boolean clone() Returns a shallow copy of this LinkedList. contains(Object o) Returns true if this list contains the specified element. E element() Retrieves, but does not remove, the head (first element) of this list. E get(int index) Returns the element at the specified position in this list. E getFirst() Returns the first element in this list. E getLast() Returns the last element in this list. int indexOf(Object o) Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element. int lastIndexOf(Object o) Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element. ListIterator<E> boolean listIterator(int index) Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. offer(E o) Adds the specified element as the tail (last element) of this list. E peek() Retrieves, but does not remove, the head (first element) of this list. E poll() Retrieves and removes the head (first element) of this list. E remove() Retrieves and removes the head (first element) of this list. E remove(int index) Removes the element at the specified position in this list. boolean remove(Object o) Removes the first occurrence of the specified element in this list. E removeFirst() Removes and returns the first element from this list. E removeLast() Removes and returns the last element from this list. E set(int index, E element) Replaces the element at the specified position in this list with the specified element. int Object[] <T> T[] size() Returns the number of elements in this list. toArray() Returns an array containing all of the elements in this list in the correct order. toArray(T[] a) Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array.