-
Notifications
You must be signed in to change notification settings - Fork 0
/
usegMultiStack.adb
96 lines (76 loc) · 2.16 KB
/
usegMultiStack.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
with gMultiStack;
with Ada.Text_IO; use Ada.Text_IO;
procedure usegMultiStack is
type NameType is (Burris, Zhou, Shashidhar, Shannon, Yang, Smith, Wei,
Rabieh, Song, Cho, Varol, Karabiyik, Cooper, McGuire, Najar, An, Deering, Hope,
Pray, NoHope);
package NameType_IO is new Ada.Text_IO.Enumeration_IO(NameType);
use NameType_IO;
type MonthName is (January, February, March, April, May, June, July,
August, September, October, November, December);
package MonthName_IO is new Ada.Text_IO.Enumeration_IO(MonthName);
package IIO is new Ada.Text_IO.Integer_IO(integer); use IIO;
type Date is record
Month: MonthName;
Day: Integer range 1..31;
Year: Integer range 1400..2020;
end record;
procedure GetDate(X: in out Date) is
begin
MonthName_IO.get(X.Month);
IIO.get(X.Day);
IIO.get(X.Year);
end GetDate;
procedure PutDate(X: Date) is
begin
MonthName_IO.put(X.Month); put(" ");
IIO.put(X.Day, 0); put(", ");
IIO.put(X.Year, 0);
end PutDate;
function DateToString(X: Date) return String is
begin
return X.month'Image & " " & X.day'Image & ", " & X.year'Image;
end DateToString;
procedure GetName(X: in out NameType) is
begin
NameType_IO.get(X);
end GetName;
procedure PutName(X: NameType) is
begin
NameType_IO.put(X);
end PutName;
function NameToString(X: NameType) return String is
begin
return X'Image;
end NameToString;
procedure GetChar(X: in out character) is
begin
get(X);
end GetChar;
procedure PutChar(X: character) is
begin
put(X);
end PutChar;
function CharToString(X: character) return String is
begin
return X'Image;
end CharToString;
procedure GetInt(X: in out integer) is
begin
IIO.get(X);
end GetInt;
procedure PutInt(X: integer) is
begin
IIO.put(X);
end PutInt;
function IntToString(X: integer) return String is
begin
return X'Image;
end IntToString;
package Go is new gMultiStack(NameType, "NameOutput.txt", GetName, PutName, NameToString);
use Go;
package Go2 is new gMultiStack(Date, "DateOutput.txt", GetDate, PutDate, DateToString);
use Go2;
begin
null;
end usegMultiStack;