comp.lang.ada
 help / color / mirror / Atom feed
From: "isaac2004" <isaac_2004@yahoo.com>
Subject: Re: making compare function with multiple values(help for newbie)
Date: 12 Oct 2006 09:21:22 -0700
Date: 2006-10-12T09:21:22-07:00	[thread overview]
Message-ID: <1160670082.448825.9820@m7g2000cwm.googlegroups.com> (raw)
In-Reply-To: <1160637884.835879.281790@e3g2000cwe.googlegroups.com>


Ludovic Brenta wrote:
> No, it is not sufficient since you didn't show the type declarations
> for the values or the arrays.
>
> Please post your entire code.  Also please keep in mind that we do not
> do students' assignments for them; instead we can help you find the
> solution for yourself.
>
> --
> Ludovic Brenta.

here is my user interaface file
WITH Ada.Text_Io;
USE Ada.Text_Io;
WITH Cats;
USE Cats;
WITH Cats.Io;
USE Cats.Io;
WITH Maximum_Array_Generic;
WITH In_Array_Generic;
PROCEDURE CompareCats IS

   -- Declare an array of cats
   TYPE CatArrayType IS ARRAY (Integer RANGE <>) OF CatType;
   Cats : CatArrayType (1 .. 5);
   -- Declare a cat variable
   Cat : CatType;
-----------------------------This is what i need to make
   --Instantiate an instance of the In_Array_Generic function.
   --This generic function determines if an element is present in an
array.

   --FUNCTION In_Array_Generic(
   --List:ArrayType;
   --Value:ValueType)RETURNBoolean;
   FUNCTION InArray IS
   NEW In_Array_Generic (
      ValueType => CatType,
      IndexType => Integer,
      ArrayType => CatArrayType);

-----------------------------------------------------------------------------

BEGIN
   -- Read data for 5 cats into the array of cats.

   FOR I IN 1..5 LOOP
      Get (Cats(I));
   END LOOP;
   -- Display the cats entered by the user.
   New_Line;
   Put_Line ("You entered ");
   FOR I IN 1..5 LOOP
      Put (Cats(I));
      New_Line;
   END LOOP;
   -- Determine and display the oldest cat.
   New_Line;
   Put ("The oldest cat is ");
   Put (MaxAge (Cats));
   New_Line;
   -- Determine and display the cat with most lives.
   Put ("The cat with the most lives is ");
   Put (MaxLives (Cats));
   New_Line;
   -- Invite the user to enter a cat and tell the user if an
   -- identical cat is in the array. Two cats are identical if
   -- they have the same id, age, and lives.
   -- Repeat until the user types cntrl-c.
   New_Line;
   Put_Line ("Enter cats and I will tell you if they are in the
array");
   Put_Line ("Type cntrl-c to quit");
   LOOP
      Get(Cat);
      IF InArray (Cats, Cat) THEN
         Put_Line ("This cat is in the array");
      ELSE
         Put_Line ("This cat is not in the array");
      END IF;
      New_Line;
   END LOOP;
END;

i hope that is enough i have other adbs and ads files if you need




  reply	other threads:[~2006-10-12 16:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-11 23:03 making compare function with multiple values(help for newbie) isaac2004
2006-10-12  5:36 ` Jeffrey R. Carter
2006-10-12  6:08   ` isaac2004
2006-10-12  7:24     ` Ludovic Brenta
2006-10-12 16:21       ` isaac2004 [this message]
2006-10-12 18:40         ` Jeffrey R. Carter
2006-10-12 18:35     ` Stephen Leake
replies disabled

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