LinkSort.adb file
with Ada.Text_IO; use Ada.Text_IO;
procedure LinkSort is
type JobType is (Accountant, Analysist, Manager, Manufacturing, Programmer, Inventory, Sales, SoftwareEnginner);
package JobTypeIO is new Ada.Text_IO.Enumeration_IO(JobType); use JobTypeIO;
type EmpName is (Ben, Betty, Bob, Damon, Darlene, David, Desire, Donald, Dustin, Jerry, Kevin, Mary, Marty, Sable, Sam, Sara, Teddy, Tom);
package EmpNameIO is new Ada.Text_IO.Enumeration_IO(EmpName); use EmpNameIO;
type LegalResponce is (yup, y, yes, affirmative, nope, no, n, negative);
subtype PositiveResponce is LegalResponce range yup..affirmative;
package LegalIO is new Ada.Text_IO.Enumeration_IO(LegalResponce); use LegalIO;
package IntIO is new Ada.Text_IO.Integer_IO(Integer); use IntIO;
type Emp is record
Name: EmpName;
Job: JobType;
age: integer;
end record;
SortByJob: Array(JobType) of integer := (others =\> 0);
SortSpace: Array(1..200) of Emp;
Avail: integer := 1; -- Dynamic storage allocator.
Pt: integer;
Again: LegalResponce := affirmative;
begin
while (Again in PositiveResponce) loop
put("Enter name: "); get(SortSpace(Avail).Name); --Get emp info.
put("Enter Job type: "); get(SortSpace(Avail).Job);
-- Insert in appropriate list (by job).
SortSpace(Avail).Next := SortByJob(SortSpace(Avail).Job);
SortByJob(SortSpace(Avail).Job) := Avail;
-- Prepare for next dynamically allocated node.
Avail := Avail + 1; --Using static array allocation as opposed dynamic linked list.
put("Enter another name (yup or nope): "); get(Again);
end loop;
-- Sort by job type.
for I in JobType loop
new_line; put("Job Type = "); put (I); new_line;
Pt := SortByJob(I); -- Point to first node in job list.
while Pt /= 0 loop
put(SortSpace(Pt).Name); put(" "); put(SortSpace(Pt).Job);
put(" link = "); put(SortSpace(Pt).Next,4); new_line;
Pt := SortSpace(Pt).Next; -- Move down list.
end loop;
end loop;
end LinkSort;
main.adb file
procedure Main is
begin
null;
end Main;
Stuck on what I should do next? I've tried to implement everything in the Ada.Text_IO in the main.adb file but errors occurred. I know i need to move something into the main file in order for the program to execute after it has been built. The output statement should be name, job type then sort space number.