Re: Help needed for ada package



With the code kindly posted by Steve and with the advice some of you
here gave me I have attempted this thing again and this is the code I
have 'written'/'modified'. I've simplified it somewhat since I am
supposed to show the concept of the procedures and functions working
regardless if they fail after a certain amount of time.

package body POP is

type Individual is
record
Person : ID;
Danger : Rating;
Associate : ID;
Reported : Boolean;
end record;

type Society is array( 1 .. 1000000 ) of Individual;

type Society_Ptr is access all Society;

Pointer : Society_Ptr;
Counter : Natrual := 0;

procedure Rate (Citizen : in ID; Badness : in Rating) is
begin
Counter := Counter + 1;
Pointer( Counter ).Person := Citizen;
Pointer( Counter ).Rating := Badness;
Pointer( Counter ).Associate := null;
Pointer( Counter ).Reported := false;
end;
end Rate;

procedure Associate (Citizen_1, Citizen_2 : in ID) is

I : Integer

for I in 0..Counter loop
if Pointer( I ).Citizen = Citizen_1
then
Pointer( I ).Associate := Citizen_2;
end if;
end Associate;

--query functions
function Most_Dangerous return ID is

MD_Counter : Integer := 1;

I : Integer

for I in 0..Counter loop
if Society(I).Danger < Society(MD_Counter).Danger then
if Society(MD_Counter).Reported = false then
begin
Most_Dangerous_Pointer := MD_Counter;
MD_Counter := MD_Counter + 1;
end;
else
MD_Counter := MD_Counter + 1;
end if;
else
MD_Counter := MD_Counter + 1;
end if;
end loop;

begin
return Pointer(Most_Dangerous_Pointer).Citizen;
Pointer(Most_Dangerous_Pointer).Reported := true;
end;

end Most_Dangerous;

I've put all the required information into an array of records. But the
problem is I realised that if a citizen has more than one associate my
code won't work. (If the code were to compile) As it stands it would
logically work if each person only had one associate. I remember an old
project using code similar to Associate : Associates.Bag within the
record instances. An I was wondering if anyone knows how this package
might look like. This way I could put Associate, Next_Member and
More_In_Group in that package as well. I think this is what the marker
is looking for as I think I'm supposed to demonstrate my program being
modular. Any comments?

.



Relevant Pages

  • Re: catch replacing useful errorInfo
    ... I can agree on all that as good general advice. ... failure, I return a message to the client (actually the application ... If a buggy package is added to the system, ... Third example allows silent failure of a documentation proc. ...
    (comp.lang.tcl)
  • Re: GUI Development Tools
    ... >> Can anyone offer any advice on GUI development tools? ... The SwellSoft PEG+ package is dearer to start with but includes ... >> many of things you pay extra for from Segger and works out to be a ...
    (comp.arch.embedded)
  • Advice needed: Packaging WSS-solutions
    ... I am currently looking into how we shall package the solution, ... Changes to underlying templates, etc are reflected in the populated ... sit down and "design" the product at customer site. ... Any advice on how-tos, tools, process, etc highly appreciated! ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Package and Deployment - Uninstalling
    ... Thanks for the advice. ... the program in the Add/Remove Programs Properties program list. ... >> One the program in installed with the Package created by the package and ... If any files the EXE is dependent upon have also been ...
    (microsoft.public.vb.general.discussion)
  • Re: GUI Development Tools
    ... > Can anyone offer any advice on GUI development tools? ... > I've been looking into the Segger EmWin tool mainly and it seems pretty ... The SwellSoft PEG+ package is dearer to start with but includes ...
    (comp.arch.embedded)