You are on page 1of 3

DEPARTAMENTODEELCTRICAYELECTRNICA

CARRERADEINGENIERADESOFTWARE

INFORMEDELABORATORIONo.20
ASIGNATURA:
CDIGO:
NRC:
PROGRAMACINII
2120316
3855
DEPARTAMENTO:
CARRERA:
ELCTRICAYELECTRNICA
INGENIERADE
SOFTWARE
DOCENTE:
ALUMNO:
ING.LUISALBERTOGUERRA
GUAMANCHAMBA
CRUZMsC
ACCELLEONARDO

NIVEL:

SEMANACLASE:
DURACIN:
II
XIII
2HORAS
READELCONOCIMIENTO:
TEMA:
PROGRAMACIN
EXCEPCIONES
FECHAREALIZACIN:
3FEBRERO2015
FECHADEENTREGA:
4FEBRERO2015

EJEDEFORMACIN:
SEGUNDAETAPA

A. FUNDAMENTACIN: EXCEPCIONES
Excepciones, o sencillamente problemas. En la programacin siempre se producen errores,
ms o menos graves, pero que hay que gestionar y tratar correctamente. Por ello en java
disponemos de un mecanismo consistente en el uso de bloques try/catch/finally

B. DESCRIPCIN:
En las excepciones se puede apreciar que cada catch se parece a una funcin en la cul slo recibimos
un objeto de un determinado tipo, precisamente el tipo del error. Es decir slo se llamar al catch cuyo
argumento sea coincidente en tipo con el tipo del error generado.

C. OBJETIVO:
Comprender el funcionamiento de las excepciones
Conocer el funcionamiento del Try Catch
D. PROYECTO:
Gestione los principios a la programacin orientada a objetos:
Analizar los conceptos de las excepciones en un programa
E. TAREAS A REALIZAR:
Implementar el cdigo para el uso de excepciones en un programa de gestion de ingreso de
Matriculas de vehiculos
F. ANLISIS:
ANLISIS DE DATOS:
Matricula char;
ANLISIS DE LAS FUNCIONES:
exMatricula();
exMatriculaValidar();
leerTeclado();
inicio();
G. DISEO:

DISEO LGICO:
H. IMPLEMENTACIN:
package practica39_exmatriculaprincipal;
import java.io.*;
class LeeTeclado{
InputStreamReader teclado;
BufferedReader lector;
LeeTeclado(){
teclado = new InputStreamReader(System.in);
lector = new BufferedReader(teclado);
}
int leeEntero() {
String auxiliar=new String();
int numero=0;
try{
auxiliar = lector.readLine();
Integer objeto=new Integer(auxiliar);
numero=objeto.intValue();
}
catch (IOException excep) {
System.out.println("Error");
}
return(numero);
}
float leeFloat() {
String auxiliar=new String();
float numero=0;
try{
auxiliar = lector.readLine();
Float objeto=new Float(auxiliar);
numero=objeto.floatValue();
}
catch (IOException excep) {
System.out.println("Error");
}
return(numero);
}
String leeString() {
String auxiliar=new String();
try{
auxiliar = lector.readLine();
}
catch (IOException excep) {
System.out.println("Error de IO");
}
return(auxiliar);
}
}
class ExMatricula extends Exception{
private int Malformada=0;
static final int mal_tamao=-1;
static final int mal_letra=-2;
ExMatricula(){
}
ExMatricula(String s){
super(s);
}
ExMatricula(int Malformada){
this.Malformada=Malformada;
}
public int DeterminarProblema(){
return Malformada;
}
}
class ExMatriculaValidar
{
private boolean Unaletra(String Matricula){
return Matricula.substring(0, 1).matches("[A-Za-z]+");
}
public void Validar(String Matricula) throws ExMatricula
{
if(Matricula.length()!=8)
throw new ExMatricula(ExMatricula.mal_tamao);
else
if(!Unaletra(Matricula))
throw new ExMatricula(ExMatricula.mal_letra);
else{
}
}
}
public class Practica39_ExMatriculaPrincipal
/**

* @param args the command line arguments


*/
public static void main(String[] args) {
// TODO code application logic here
ExMatriculaValidar LaMatricula=new ExMatriculaValidar();
do
try{
System.out.println("Ingrese la Matricula:");
LeeTeclado teclado= new LeeTeclado();
String Matricula= teclado.leeString();
LaMatricula.Validar(Matricula);
}
catch(ExMatricula e)
{
switch(e.DeterminarProblema()){
case ExMatricula.mal_tamao:
System.out.println("Tamao Incorrecto");
break;
case ExMatricula.mal_letra:
System.out.println("Letra Inicial no Incluida");
break;
default:
System.out.println("Matricula Correcta");
break;
}
}
while(true);
}
}

I. PRUEBAS:

J. REPORTE:
REQUERIMIENTO
SFUNCIONALES

ANLISIS

DISEO

IMPLEMENTACIN

PRUEBAS

exMatricula
exMatriculaValidar
leerTeclado
main();
CALIFICACIN

K. RESULTADOS Y CONCLUSIONES:

Al terminar esta practica-deber se pudo obtener un mejor conocimiento del uso de excepciones
Conocer el funcionamiento del try catch

L. ACTIVIDADES SEGN CRONOGRAMA:


PRIMERA ENTREGA:
Excepciones en java

4 de febrero del 2015

M. REFERENCIAS BIBLIOGRFICAS:

Nombre de la obra:
Nombre de autor (es):
Editorial:
Ao de edicin:

Apuntes de clases sobre Sentencias de Control.


Ing Luis Guerra.
ESPE
2014

NOTA

You might also like