--------------------------------------------------------------------- -- AUTOR: Eduardo Jiménez Chapresto -- PROYECTO: Ejercicio de examen Ing. Industrial sep. 1998 -- FICHERO: bola.adb -- FECHA: 6 de enero del 2000 -- Modificado por: -- OBJETIVO: Simular el comportamiento de una bola que se deja caer en -- una casilla de un tablero con alturas definidas en un fichero, -- matriz.txt. --------------------------------------------------------------------- with ada.text_io, ada.integer_text_io; use ada.text_io, ada.integer_text_io; procedure bola is COLMAT :constant integer:=10; FILMAT :constant integer:=10; ALTURAMAX:constant integer:=20; type tpMatriz is array(1..COLMAT,1..FILMAT) of integer range 0..ALTURAMAX; type tpPunto is record x :integer; --range 1..COLMAT; y :integer; --range 1..FILMAT; end record; matriz :tpMatriz; fichero :file_type; punto,final :tpPunto; procedure leeMatriz(fichero:in file_type; matriz:out tpMatriz) is i,j :integer; begin i:=0; while not End_Of_File(fichero) loop i:=i+1; j:=0; while not End_Of_Line(fichero) loop j:=j+1; get(fichero, matriz(j,i)); end loop; skip_line(fichero); end loop; end leeMatriz; function posValida(x:in integer;y:in integer) return boolean is begin if x>0 and x<11 and y>0 and y<11 then return TRUE; else return FALSE; end if; end posValida; function trayectoBola(matriz:in tpMatriz; p:in tpPunto) return tpPunto is aux,punto,ant:tpPunto; alt :integer range 0..ALTURAMAX; begin punto:=p; ant.x:=punto.x+1; while ant/=punto loop aux:=punto; ant:=punto; alt:=matriz(punto.x, punto.y); if posValida(punto.x - 1, punto.y) then if matriz(punto.x - 1, punto.y)