Lecture 8 – September  19, 2007

Ada has three parameter modes:  in,  out,  in out

In parameters can be read from

Out parameters can be written to

If you want to do both in your sub-program,  make them in out

 

If you had trouble with your reduce fraction method – go to Wikipedia for greatest common factor and read the material there  OR look for Euclid’s algorithm and program it.

 

Write a test program to test our FRACTION ADT

Test makeFraction

·         Numerator = 2,  denominator = 7

·         Numerator = 8,  denominator = 0  ( this one should raise and handle an exception)

·         Numerator = 12,  denominator = 5

·         Numerator = 2,  denominator = 4   (this should call the reduce function)

 

To see if makeFraction worked we need to be able to print the fraction

 We looked at  parts of the Bingo case study

In Bingo_card,  we learned we could declare our own exceptions

If you want your own exception, you need to do 3 things:

·        Declare it      exception_name   : exception;

·        Raise it 

·        Handle it

 

Print out the code examples from Bingo Chapter 2 (use the URL on the Web page)

and bring those printouts and the handout I gave out in class today to class on Monday.