comp.lang.ada
 help / color / mirror / Atom feed
* Enormous problems in one of my programs!
@ 2002-05-24 10:13 Kladde
  2002-05-24 13:35 ` Ted Dennison
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Kladde @ 2002-05-24 10:13 UTC (permalink / raw)


Helllo! I have a home assignment in ADA, and sice Im not used to this
language I need some help, I would be very greatful. Below I will
insert a start, header and body file and any faults or problems you
can find I will be very happy for. Under the code I will insert the
compile failures I get when trying to compile.

All help is greatly appreciated!!


//***********************

START FILE (shouldnt contain any faults since it came with the package
i got at the start of the course):

//***************************


with Fibonacci;
use Fibonacci;

procedure Starter is
        
begin  
   Random_F.Reset(Gen =>Randomizer);  -- initialize random generator
      Island.Breed;                   -- creates first two rabbits
   end;



//********************************

DECLARATION FILE (.ads file, shouldnt contain any faults either since
it too came with the package):

//********************************




with Ada.Numerics.Discrete_Random;
with Ada.Text_Io;

package Fibonacci is

  

   task type Female is                -- Server task specification
      entry Multiply; 
   end Female;

   type Server_P is access Female;    -- Type for Pointers to Server
tasks

   task type Male;                    -- Client task specification
   
   type Client_P is access Male;      -- Type for Pointers to Client
tasks

   type Servers is array (1 .. 100) of Server_P;   
   type Clients is array (1 .. 100) of Client_P; 


   subtype F_Index is Integer range 1 .. 100;  -- Support for
randomness in selection of servers
   package Random_F is
      new Ada.Numerics.Discrete_Random(Result_Subtype => F_Index);
      
     -- Hint : Temp:=(Random_F.Random(Gen => Randomizer) mod 17)+1;
assigns a


   Randomizer : Random_F.Generator; -- Generator of psudo-randomnes  


   protected type Island_T is          -- protected object definition


   private
      Pairs : Integer := 0;
      Females : Servers;
      Males : Clients;


      entry Get_Random_Female (
            Female :    out Server_P );
 
      procedure Breed; 


   end Island_T;

   Island : Island_T;                -- a protected object for
resource control

end Fibonacci;


//***************************


BODY FILE (this is the one that contains the faults since its the one
that I made :-))

//***************************


with Ada.Numerics.Discrete_Random;
with Ada.Text_Io;
package body Fibonacci is




--H�R �R KVINNAN



task body Female is
  begin
  loop
    
    accept Multiply do
      Island.Breed;
    end Multiply;
    
  end loop;
  
end Female;
 
 

-- H�r �r mannen
 
task body Male is
  temp : Female;
  begin
    delay 20.0;
    loop
      temp := Island.Get_Random_Female;
      loop
        select
          temp.Multiply;
        or
          delay 3.0;
        end select;
      end loop;
      delay 2.0;
    end loop;
 
end Male;
 
 
 -- H�r �r �n

protected body Island is

   begin
 
  accept Get_Random_Female(hona: out Server_P) do
    hona := honor(par);
    return;
  end Get_Random_Female;


  procedure Breed is
    begin
      if(par <= 100) then
        hanar(par) := new Male;
        honor(par) := new Female;
        par := par+1;
    end if;  
    end Breed;
    
end Island;
 
end Fibonacci;



//*********************

Here are the errors that the program produces

//************************

fibonacci.adb:51:03: missing "end Island;"
fibonacci.adb:59:03: declarations must come before "begin"
fibonacci.adb:68:01: "end Fibonnaci;" expected



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-05-25 15:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-24 10:13 Enormous problems in one of my programs! Kladde
2002-05-24 13:35 ` Ted Dennison
2002-05-24 13:57   ` Andreas Lans
2002-05-24 14:55 ` Preben Randhol
2002-05-24 15:26   ` Andreas Lans
2002-05-24 17:14 ` Stephen Leake
2002-05-25  1:26   ` Liao Choon Way
2002-05-25 15:31     ` Adrian Hoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox