home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / answers / ch06_3.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  605 b   |  29 lines

  1.                               -- Chapter 6 - Programming exercise 3
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Ch07_3 is
  6.  
  7. type MY_ENUM is (YES, NO, MAYBE, WHY, POSSIBLY);
  8.  
  9. Answer : MY_ENUM := YES;
  10.  
  11. begin
  12.    Answer := MY_ENUM'PRED(Answer);
  13. end Ch07_3;
  14.  
  15.  
  16.  
  17.  
  18. -- Result of execution
  19.  
  20. -- Exception never handled: constraint_error
  21. -- Value 0 out of range 1..4.
  22.  
  23. -- (This means that since the range of the enumerated variable
  24. --  only covers four values, trying to assign the value of zero,
  25. --  which is one less than the allowed minimum causes us to go
  26. --  out of the allowable range. )
  27.  
  28.  
  29.