APO1 - Presentacion nivel 1
-
Upload
mario-jose-villamizar-cano -
Category
Education
-
view
6.905 -
download
5
description
Transcript of APO1 - Presentacion nivel 1
![Page 1: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/1.jpg)
BIENVENIDOS A ALGORÍTMICA Y PROGRAMACIÓN 1 (APO 1)
NIVEL 1
Mario José Villamizar Cano
Oficina ML-637
http://sistemas.uniandes.edu.co/~mj.villamizar24/dokuwiki/doku.php
Grupo de Tecnologías de Información y Comunicación (COMIT)
Departamento de Ingeniería de Sistemas y Computación
Universidad de los Andes, Bogotá D.C., Colombia
![Page 2: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/2.jpg)
http://twitter.com/mariocloud
http://linkedin.com/in/mariojosevillamizarcano
REDES SOCIALES
NIVEL 1
![Page 3: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/3.jpg)
INTRODUCCIÓN Y REGLAS DE JUEGO
Entrega del programa
Presentación del curso
Organización del curso (cronogramas)
Metodología
Reglas de juego
Medios de comunicación profesor-estudiante
Libro del curso
Monitores
Esquema de evaluación
NIVEL 1
![Page 4: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/4.jpg)
PLAN DE TEMAS
NIVEL 1
![Page 5: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/5.jpg)
ESQUEMA DE EVALUACIÓN
NIVEL 1
![Page 6: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/6.jpg)
Proceso global de solución de un problema usando un programa de
computador
Analizar un problema simple que se va a resolver usando un
programa de computador
Explicar la estructura de un programa de computador
Completar una solución parcial a un problema
Utilizar un ambiente de desarrollo de programas y un espacio de
trabajo predefinido
NIVEL 1 – PROBLEMAS, SOLUCIONES Y PROGRAMAS
NIVEL 1
![Page 7: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/7.jpg)
CASOS DE ESTUDIO
Caso de estudio 1: El Empleado
NIVEL 1
![Page 8: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/8.jpg)
CASOS DE ESTUDIO
Caso de estudio 2: Simulador Bancario
NIVEL 1
![Page 9: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/9.jpg)
CASOS DE ESTUDIO
Caso de estudio 3: El triángulo
NIVEL 1
![Page 10: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/10.jpg)
HOJAS DE TRABAJO
Hoja de trabajo 1: La alcancía
NIVEL 1
![Page 11: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/11.jpg)
HOJAS DE TRABAJO
Hoja de trabajo 2: La encuesta
NIVEL 1
![Page 12: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/12.jpg)
PROCESO PARA SOLUCIONAR UN PROBLEMA
NIVEL 1
![Page 13: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/13.jpg)
ETAPAS DEL PROCESO DE SOLUCIÓN A UN PROBLEMA
NIVEL 1
![Page 14: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/14.jpg)
ANÁLISIS DEL PROBLEMA
Entender el problema del cliente y qué es lo que se quiere hacer.
La salida de esta etapa se denomina especificación del problema.
NIVEL 1
![Page 15: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/15.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS FUNCIONALES
Requerimiento funcional: Operación o servicio que el programa que se
va a construir debe proveer al usuario.
Elementos de un requerimiento funcional
Identificador y nombre
Resumen de la operación
Entrada
Resultados (modificación de un valor, cálculo de un valor, mezcla)
NIVEL 1
![Page 16: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/16.jpg)
ANÁLISIS DEL PROBLEMA – EL PROBLEMA
EL EMPLEADO
NIVEL 1
![Page 17: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/17.jpg)
ANÁLISIS DEL PROBLEMA – EL PROBLEMA
SIMULADOR BANCARIO
NIVEL 1
![Page 18: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/18.jpg)
ANÁLISIS DEL PROBLEMA – EL PROBLEMA
EL TRIÁNGULO
NIVEL 1
![Page 19: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/19.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS FUNCIONALES
EJEMPLO DEL EMPLEADO
Requerimientos funcionales del ejemplo:
R1 - Ingresar la información del empleado
R2 - Actualizar el salario básico del empleado
R3 - Calcular la edad del empleado
R4 - Calcular de la antigüedad del empleado
R5 - Calcular las prestaciones de un empleado
NIVEL 1
![Page 20: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/20.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS FUNCIONALES
EJEMPLO 1
NIVEL 1
![Page 21: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/21.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS FUNCIONALES
EJEMPLO 2
NIVEL 1
![Page 22: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/22.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS FUNCIONALES
EJEMPLO 3
NIVEL 1
![Page 23: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/23.jpg)
ANÁLISIS DEL PROBLEMA – MUNDO DEL PROBLEMA
Entendimiento detallado del mundo en el que ocurre el problema y
definición del Mundo del Problema. Para lograr esto se debe:
Identificar las entidades (clases)
Modelar las características (atributos, posibles valores)
Las relaciones entre las entidades
El modelo del mundo será expresado utilizando el lenguaje UML (Unified
Modeling Languaje)
NIVEL 1
![Page 24: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/24.jpg)
ANÁLISIS DEL PROBLEMA – MUNDO DEL PROBLEMA
EJEMPLO DEL EMPLEADO
Empleado
nombre apellido sexo salario
Fecha
dia mes anio
fechaNacimiento
fechaIngreso
NIVEL 1
![Page 25: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/25.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS FUNCIONALES
EJEMPLO DEL TRIÁNGULO
Requerimientos funcionales del ejemplo:
R1 - Crear un nuevo triangulo
R2 - Calcular área del triangulo
R3 - Calcular perímetro del triángulo
R4 - Cambiar color relleno
R5 - Cambiar color de las líneas
NIVEL 1
![Page 26: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/26.jpg)
ANÁLISIS DEL PROBLEMA – MUNDO DEL PROBLEMA
EJEMPLO DEL TRIÁNGULO
Triangulo Punto
x y
punto1
punto2
punto3
Color
rojo verde azul
colorLineas colorRelleno
NIVEL 1
![Page 27: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/27.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS FUNCIONALES
EJEMPLO DEL SIMULADOR BANCARIO
Requerimientos funcionales del ejemplo:
R1 - Consignar en la cuenta corriente
R2 - Consignar en la cuenta de ahorros
R3 - Invertir en un CDT
R4 - Calcular el saldo total de un cliente del banco
R5 - Avanzar la fecha de la simulación en un mes
R6 - Retirar de la cuenta de ahorros
R7 - Retirar de la cuenta corriente
R8 - Cerrar el CDT y pasar a la cuenta corriente
R9 - Dar el saldo de la cuenta corriente
R10 - Dar el saldo de la cuenta de ahorros
NIVEL 1
![Page 28: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/28.jpg)
ANÁLISIS DEL PROBLEMA – MUNDO DEL PROBLEMA
EJEMPLO DEL SIMULADOR BANCARIO
NIVEL 1
CuentaBancaria
cedula nombre
CuentaCorriente
saldo corriente
Mes
mes
mesActual
mesApertura
CuentaAhorros
saldo interesMensual
CDT
valorInvertido interesMensual
ahorros
inversion
![Page 29: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/29.jpg)
ANÁLISIS DEL PROBLEMA – REQUERIMIENTOS NO FUNCIONALES
Restricciones definidas por el cliente.
En este curso sólo se tendrán en cuenta requerimientos no funcionales
relacionados con la interacción del usuario y la visualización de la
información.
NIVEL 1
![Page 30: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/30.jpg)
ETAPAS GENERALES DEL PROCESO DE SOLUCIÓN
A UN PROBLEMA
NIVEL 1
![Page 31: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/31.jpg)
SOLUCIÓN A UN PROBLEMA
NIVEL 1
![Page 32: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/32.jpg)
SOLUCIÓN A UN PROBLEMA
NIVEL 1
![Page 33: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/33.jpg)
ETAPAS GENERALES DEL PROCESO DE SOLUCIÓN
A UN PROBLEMA
NIVEL 1
![Page 34: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/34.jpg)
DISEÑO DE LA SOLUCIÓN
Interfaz de usuario
Arquitectura de la solución
Diseño de las clases
NIVEL 1
![Page 35: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/35.jpg)
DISEÑO DE LA SOLUCIÓN – INTERFAZ DE USUARIO
NIVEL 1
![Page 36: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/36.jpg)
DISEÑO DE LA SOLUCIÓN – INTERFAZ DE USUARIO (2)
NIVEL 1
![Page 37: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/37.jpg)
DISEÑO DE LA SOLUCIÓN – ARQUITECTURA DE LA SOLUCIÓN
NIVEL 1
Todo el trabajo de los niveles 1 al 4 se
desarrolla en las clases que se encuentran
en este paquete
Para verificar que los ejercicios desde el nivel 1
hasta el 4 están bien, deben utilizar
las clases de este paquete.
NO deben modificar las clases de
este paquete durante TODO el curso.
Desde el nivel 1 hasta el nivel 4 NO deben
modificar las clases de este paquete.
![Page 38: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/38.jpg)
ETAPAS GENERALES DEL PROCESO DE SOLUCIÓN
A UN PROBLEMA
NIVEL 1
![Page 39: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/39.jpg)
ETAPAS GENERALES DEL PROCESO DE SOLUCIÓN
A UN PROBLEMA
NIVEL 1
![Page 40: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/40.jpg)
CONSTRUCCIÓN DE LA SOLUCIÓN – TIPOS DE ARCHIVOS
NIVEL 1
![Page 41: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/41.jpg)
CONSTRUCCIÓN DE LA SOLUCIÓN – ORGANIZACIÓN DE LOS
ELEMENTOS DE TRABAJO
NIVEL 1
![Page 42: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/42.jpg)
CONSTRUCCIÓN DE LA SOLUCIÓN – ORGANIZACIÓN DE LOS
ELEMENTOS DE TRABAJO
NIVEL 1
![Page 43: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/43.jpg)
ETAPAS GENERALES DEL PROCESO DE SOLUCIÓN
A UN PROBLEMA (4)
NIVEL 1
![Page 44: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/44.jpg)
Laboratorio 1
N1_T1 - Uso básico de Eclipse.pdf
http://cupi2.uniandes.edu.co/sitio/imag
es/cursosCupi2/apo1/talleres/n1lab_20
061_MarcelaHernandez.pdf
NIVEL 1
![Page 45: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/45.jpg)
PREGUNTAS
NIVEL 1
![Page 46: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/46.jpg)
ALGORITMO E INSTRUCCIONES
Algoritmo: Conjunto ordenado de pasos o instrucciones que deben ser
realizados con el fin de solucionar un problema o requerimiento funcional.
Instrucción: Conjunto de expresiones y operadores aritméticos que hacen
parte de uno de los pasos ejecutados durante un algoritmo.
NIVEL 1
Algoritmo para ir a la universidad
• Instrucción 1: Levantarse
• Instrucción 2: Cepillarse
• Instrucción 3: Bañarse
• Instrucción 4: Vestirse
• Instrucción 5: Desayunar
• Instrucción 6: Recoger el bolso o maletín
• Instrucción 7: Despedirse de la familia
• Instrucción 8: Salir y tomar el bus, ó sacar e ir en el carro
• Instrucción 9: Llegar a la universidad
![Page 47: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/47.jpg)
TIPOS DE DATOS
Tipos de datos: Cada atributo de una clase debe tener el tipo de dato
asociado, entre los que se encuentran los valores enteros (int), los reales
(double) y las cadenas de caracteres (String).
NIVEL 1
Estudiante
String nombre String apellido int sexo double promedio
Empleado
String nombre String apellido int sexo int salario
![Page 48: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/48.jpg)
ANÁLISIS DEL PROBLEMA – MUNDO DEL PROBLEMA
EL EMPLEADO
Empleado
nombre apellido sexo salario
Fecha
dia mes anio
fechaNacimiento
fechaIngreso
NIVEL 1
![Page 49: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/49.jpg)
DISEÑO DEL PROBLEMA – DIAGRAMA DE CLASES
EL EMPLEADO
Empleado
String nombre String apellido int sexo int salario
Fecha
int dia int mes int anio
fechaNacimiento
fechaIngreso
NIVEL 1
![Page 50: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/50.jpg)
ANÁLISIS DEL PROBLEMA – MUNDO DEL PROBLEMA
EJEMPLO DEL TRIÁNGULO
Triangulo Punto
x y
punto1
punto2
punto3
Color
rojo verde azul
colorLineas colorRelleno
NIVEL 1
![Page 51: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/51.jpg)
DISEÑO DEL PROBLEMA – DIAGRAMA DE CLASES
EL TRIÁNGULO
Triangulo Punto
double x double y
punto1
punto2
punto3
Color
int rojo int verde int azul
colorLineas colorRelleno
NIVEL 1
![Page 52: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/52.jpg)
ANÁLISIS DEL PROBLEMA – MUNDO DEL PROBLEMA
SIMULADOR BANCARIO
CuentaBancaria
cedula nombre
CuentaCorriente
saldo corriente
Mes
mes
mesActual
mesApertura
CuentaAhorros
saldo interesMensual
CDT
valorInvertido interesMensual
ahorros
inversion
NIVEL 1
![Page 53: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/53.jpg)
DISEÑO DEL PROBLEMA – DIAGRAMA DE CLASES
SIMULADOR BANCARIO
Cuenta Bancaria
String cedula String nombre
CuentaCorriente
int saldo corriente
Mes
int mes
mesActual
mesApertura
CuentaAhorros
int saldo double interesMensual
CDT
int valorInvertido double interesMensual
ahorros
inversion
NIVEL 1
![Page 54: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/54.jpg)
CLASES Y OBJETOS
Clase: Identifica una entidad general dentro del modelo mundo que tiene
asociado un conjunto de atributos y métodos.
Objeto: Identifica una instancia específica de una clase que tiene valores
específicos para cada uno de los atributos de la clase.
NIVEL 1
Estudiante
String nombre String apellido int sexo double promedio
nombre = “Ricardo Jorge”
apellido = “Torres”
sexo = Masculino
promedio = 4.14
:Estudiante
nombre = “María”
apellido = “González”
sexo = Femenino
promedio = 4.82
:Estudiante
nombre = “Pepito”
apellido = “Pérez”
sexo = Masculino
promedio = 3.12
:Estudiante
1 Clase 1 o más objetos Instanciar o crear
![Page 55: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/55.jpg)
DECLARACIÓN DE UNA CLASE
Declaración de una clase:
Cada clase de declara en un archivo .java. Ejemplo: Empleado.java
package uniandes.cupi2.empleado.mundo;
/**
* Esta clase representa un empleado
*/
public class Empleado
{
//------------------------------------------------
// Atributos
//------------------------------------------------
. . .
//------------------------------------------------
// Métodos
//------------------------------------------------
. . .
}
NIVEL 1
![Page 56: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/56.jpg)
DECLARACIÓN DE LOS ATRIBUTOS Y COMENTARIOS
Declaración de un atributo:
Todos los atributos son privados y se definen con la forma: private TipoAtributo nombreAtributo;
public class Empleado
{
//------------------------------------------------
// Atributos
//------------------------------------------------
/**
* Nombre
*/
private String nombre;
. . .
}
NIVEL 1
![Page 57: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/57.jpg)
EJERCICIOS EN CLASE
CASO DE ESTUDIO: EMPLEADO
NIVEL 1
![Page 58: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/58.jpg)
EJERCICIOS EN CLASE
CASO DE ESTUDIO: EMPLEADO
Empleado
String nombre String apellido int sexo int salario
Fecha
int dia int mes int anio
fechaNacimiento
fechaIngreso
NIVEL 1
![Page 59: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/59.jpg)
EJERCICIOS EN CLASE
CASO DE ESTUDIO: EMPLEADO
fechaNacimiento
fechaIngreso
prestaciones = (antiguedad * salario)/12
NIVEL 1
nombre = “Andres”
apellido = “Rodriguez”
sexo = Masculino
salario = 1000000
:Empleado dia = 1
mes = 1
anio = 1970
:Fecha
dia = 12
mes = 12
anio = 1999
:Fecha
![Page 60: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/60.jpg)
MÉTODOS
Método: Especifica el comportamiento o un algoritmo que debe ser
ejecutado por los objetos de una clase. Una clase puede tener tantos métodos
como sean necesarios.
En el nivel 1 deberán completar el cuerpo de los métodos ya definidos
(métodos con TODO). No deberán crear nuevos métodos en ningún caso.
Definición de un método en la clase Empleado e instrucción de retorno
/**
* Retorna el nombre del empleado
* @return nombre
*/
public String darNombre( )
{
return nombre;
}
NIVEL 1
![Page 61: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/61.jpg)
MÉTODOS – EL EMPLEADO
Definición de un método en la clase Empleado e instrucción de retorno
/**
* Retorna el salario del empleado
* @return salario
*/
public int darSalario( )
{
return salario;
}
/**
* Cambia el salario del empleado. <br>
* <b>post: </b> salario = pSalario.
* @param pSalario El nuevo salario del empleado.
*/
public void cambiarSalario( int pSalario )
{
salario = pSalario;
}
NIVEL 1
![Page 62: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/62.jpg)
MÉTODOS - EL EMPLEADO
Completar los siguientes métodos
/**
* Retorna el sexo del empleado
* @return sexo
*/
public int darSexo ( )
{
____________________________
}
/**
* Duplica el salario del empleado. <br>
* <b>post: </b> salario = salario*2.
*/
public void duplicarSalario( )
{
____________________________
}
NIVEL 1
![Page 63: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/63.jpg)
MÉTODOS - EL EMPLEADO
Completar los siguientes métodos
/**
* Cambia la fecha de ingreso del empleado. <br>
* <b>post: </b> fechaIngreso = pFechaIngreso.
* @param pFechaIngreso La nueva fecha de ingreso del empleado.
* pFechaIngreso != null.
*/
public void cambiarFechaIngreso( Fecha pFechaIngreso )
{
____________________________
}
/**
* Retorna la fecha de nacimiento del empleado
* @return fachaNacimiento
*/
public Fecha darFechaNacimiento ( )
{
____________________________
}
NIVEL 1
![Page 64: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/64.jpg)
OPERADORES ARITMÉTICOS
+ (suma)
- (resta)
* (multiplicación)
/ (división)
( ) (paréntesis)
Nota: Es importante colocar paréntesis para evitar ambigüedad en las
expresiones.
Orden de evaluación
Primero se aplican los paréntesis.
Luego se aplican los operadores de multiplicación y división, de
izquierda a derecha.
Después se aplican los operadores de suma y resta, de izquierda a
derecha.
NIVEL 1
![Page 65: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/65.jpg)
MÉTODOS - EL EMPLEADO
Completar los siguientes métodos
/**
* Retorna el porcentaje del salario para aportes a salud con <br>
* base en el porcentaje recibido como parámetro <br>
* @param pSalud El porcentaje de aportes a salud.
* @return valorAporteSalud
*/
public double darValorAporteSalud (int pSalud )
{
____________________________
}
/**
* Incrementa el salario del empleado en el porcentaje recibido como <br>
* parámetro. <br>
* @param pIncremento El porcentaje de incremento del salario.
* <b>post: </b> salario = salario + salario * pIncremento / 100.
*/
public void incrementarSalario(int pIncremento )
{
____________________________
}
NIVEL 1
![Page 66: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/66.jpg)
PREGUNTAS
NIVEL 1
![Page 67: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/67.jpg)
Laboratorio 2
N1_T2: Inicio en Java
http://cupi2.uniandes.edu.co/sitio/imag
es/cursosCupi2/apo1/talleres/n1lab_20
061_APO1-GUIA-N1-L2.doc
NIVEL 1
![Page 68: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/68.jpg)
EJERCICIOS EN CLASE
CASO DE ESTUDIO: SIMULADOR BANCARIO
NIVEL 1
![Page 69: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/69.jpg)
EJERCICIOS EN CLASE
CASO DE ESTUDIO: SIMULADOR BANCARIO
CuentaBancaria
String cedula String nombre
CuentaCorriente
int saldo corriente
Mes
int mes
mesActual
mesApertura
CuentaAhorros
int saldo double interesMensual
CDT
int valorInvertido double interesMensual
ahorros
inversion
NIVEL 1
![Page 70: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/70.jpg)
EJERCICIOS EN CLASE
CASO DE ESTUDIO: SIMULADOR BANCARIO
corriente
mesActual
mesApertura
ahorros
inversion
NIVEL 1
cedula = “13456789” nombre = “Juan Pérez”
: CuentaBancaria saldo = 1000000
: CuentaCorriente
saldo = 1000000 interesMensual = 10
: CuentaAhorros
valorInvertido = 500000 interesMensual = 10
: CDT
mes = 1
: Mes
mes = 1
: Mes
![Page 71: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/71.jpg)
MÉTODOS – SIMULADOR BANCARIO
Instrucción de llamada a un método
Llamada de métodos con parámetros
Realizar los 10 ejercicios del nivel 1
SIMULADOR BANCARIO
NIVEL 1
![Page 72: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/72.jpg)
RECOMENDACIONES SOBRE EL EJERCICIO
Diligenciar los requerimientos funcionales.
Documentar los atributos o métodos que se requieran.
Revisar todos los TODO.
No borrar los TODO.
NIVEL 1
![Page 73: APO1 - Presentacion nivel 1](https://reader034.fdocuments.mx/reader034/viewer/2022052211/557b3a9ad8b42a6d698b4cee/html5/thumbnails/73.jpg)
PREGUNTAS
NIVEL 1