Descargar la presentación
La descarga está en progreso. Por favor, espere
Publicada porJosé Miguel Olivera Lara Modificado hace 7 años
1
Diseño y Programación Orientada a Objetos
Conferencia # 5: Caso de estudio integrador: Control docente Facultad Ing. Informática ISPJAE
2
Se desea automatizar el procesamiento de la información final de un curso de los estudiantes de un año, conociendo los datos de cada estudiante, los datos de cada asignatura y la nota de cada estudiante en cada asignatura.
3
De los estudiantes se conoce nombre, grupo, si es becado o no y el promedio final de los cursos anteriores. De cada asignatura se conoce, nombre, cantidad de horas presenciales y semestre en que se impartió.
4
Requerimientos funcionales.
Total de horas presenciales del año. Modificar la nota de un estudiante en una asignatura dada. % de aprobados de una asignatura.
5
Promedio de un estudiante, solo si tiene todas las asignaturas aprobadas y actualizar su registro de promedios. % de becados suspensos en el curso. Cantidad de estudiantes que terminaron el 1er semestre con tres o más asignaturas suspensas.
6
¿Modelo de datos?
7
Estudiantes j Asignaturas i Nota en asignatura i del estudiante j
8
Diseños de clases
9
Variante 1 Controler IntMatrix mark Student Course String name
0..* 1 0..* Student String name String group boolean scholarship FloatArray average Course String name int hour int semester
10
Variante 2 Controller IntMatrix mark StudentCollection
1 1 1 1 StudentCollection CourseCollection 1 1 0..* 0..* Student Course
11
Variante 3 1 1 1 1 Controller 1 1 StudentCollection CourseCollection 1
Mark IntMatrix mark 1 1 1 1 Controller 1 1 StudentCollection CourseCollection 1 1 0..* 0..* Student Course
12
Implementación Variante 2
13
public class Student { private String name; private String group; private boolean scholarship; private FloatArray average; public Student(String name, String group, boolean scholarship) { this.name = name; this.group = group; this.scholarship = scholarship; average = new FloatArray(); } ...
14
public String getGroup(){return group;}
public String getName() {return name;} public boolean getScholarship() {…} public void setGroup(String group) {…} public void setName(String name) {…} public void setScholarship(…) {…}
15
public float getAverageInYear(int
if(year>0 && year<average.getCount()) return average.get(year-1); else return -1; } public void setAverageInYear(int year, float value) { average.set(year-1,value);
16
public boolean addAverage(float
value) { if(average.getCount() < 5) { average.add(value); return true; } else return false;
17
public class Course { private String name; private int hour; private int semester; public Course(String name, int hour, int semester) { this.name = name; this.hour = hour; this.semester = semester; } … }
18
public class StudentCollection {
private Student[] students; private int count; public static final int DEFAULT_CAPACITY = 10; private void ensureCapcity(int minCapacity){…} private boolean rangeIsValid (int index) { if(index >= 0 && index < count) return true; else return false; }
19
public StudentCollection() {
this(DEFAULT_CAPACITY);} public StudentCollection(int capacity) { if (capacity > 0) students = new Student[capacity]; else students = new Student[DEFAULT_CAPACITY]; }
20
public int getCount() {return count;}
public int find(String name) { int i=0; while (i < count && !students[i].getName(). equalsIgnoreCase(name)) i++; return i < count? i : -1; }
21
public boolean add(String name,
String group, boolean scholarship) { boolean result = false; if (find(name) == -1){ if (count == students.length) ensureCapacity(1); students[count++] = new Student(name,group,scholarship); result = true; } return result; }
22
public float getAverage(String name,
int year) { int pos = find(name); if (pos != -1) return students[pos].getAverageInYear(year); else return -1; } … }
23
public class CourseCollection {
private Course[] courses; private int count; public static final int DEFAULT_CAPACITY = 10; …
24
public int totalHours(){
//Total de horas presenciales int sum= 0; for(int i= 0; i < count; i++) sum += courses[i].getHour(); return sum; } …}
25
public class Secretary {
private CourseCollection courses; private StudentCollection students; private IntMatrix marks;
26
public Secretary () { courses= new CourseCollection(); students= new StudentCollection(); marks= new IntMatrix(courses.DEFAULT_CAPACITY, students.DEFAULT_CAPACITY); }
27
public Secretary (int capacityCourses,
int capacityStudents) { … } public boolean addStudent(String name, String group,boolean scholarship) { boolean result = students.add(name,group,scholarship); if (result) marks.addColZero(); return result;}
28
public int getMark(String course, String student) {
int row = courses.find(course); int col = students.find(student); if (row != -1 && col != -1) return marks.get(row, col); else return -1; }
29
public boolean setMark(String course, String student, int value) {
int row = courses.find(course); int col = students.find(student); if (row != -1 && col != -1) { marks.set(row, col, value); return true; } else return false;
30
% de aprobados de una asignatura.
public float percentApproved(String course) { int row = courses.find(course); if (row == -1) return -1; else { int countApproved= marks.countBiggerThan(row,0, row,marks.getColCount()-1,2); return (float)countApproved / marks.getColCount()* 100; } }
31
public int totalHours() {
//Total de horas presenciales return courses.totalHours(); }
32
Conclusiones Consistencia en el enfoque OO
Utilidad de clases generales Responsabilidades compartidas
33
Estudio Independiente
Completar la implementación de los requerimientos funcionales especificados. Implementar la Variante 3.
Presentaciones similares
© 2025 SlidePlayer.es Inc.
All rights reserved.