
C9-1
Algorithm
Package Specification
1. Declare the type.
2. Create a new package within the package specification to provide predefined
functions for the enumeration type.
3. Declare the function prototypes for both the predecessor and successor functions.
Package Implementation
1. Successor function:
a. if the input_value = Type’Last then
return Type’First
b. else return Type’Succ(input_value);
2. Predecessor function:
a. if the input_value = Type’First then
return Type’Last
b. else return Type’Pred(input_value);
Code Listing
Checking: c:/docume~2/jk/desktop/16070/codeso~1/my_type_package.ads (source file time stamp: 2003-
09-24 01:59:20)
1. -----------------------------------------------------------
2. -- Package specified to declare the type and two functions
3. -- Specifier : Jayakanth Srinivasan
4. -- Date Last Modified : 09/23/2003
5. -----------------------------------------------------------
6.
7. with Ada.Text_Io;
8.
9. package My_Type_Package is
10.
11. type Day is
12. (Monday,
13. Tuesday,
14. Wednesday,
15. Thursday,
16. Friday,
17. Saturday,
18. Sunday);