c392003.a

来自「linux下编程用 编译软件」· A 代码 · 共 454 行 · 第 1/2 页

A
454
字号
-- C392003.A----                             Grant of Unlimited Rights----     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained --     unlimited rights in the software and documentation contained herein.--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making --     this public release, the Government intends to confer upon all --     recipients unlimited rights  equal to those held by the Government.  --     These rights include rights to use, duplicate, release or disclose the --     released technical data and computer software in whole or in part, in --     any manner and for any purpose whatsoever, and to have or permit others --     to do so.----                                    DISCLAIMER----     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED --     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE --     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A--     PARTICULAR PURPOSE OF SAID MATERIAL.--*---- OBJECTIVE:--      Check that the use of a class-wide formal parameter allows for the --      proper dispatching of objects to the appropriate implementation of --      a primitive operation.  Check this where the root tagged type is--      defined in a package, and the extended type is defined in a nested--      package.---- TEST DESCRIPTION:--      Declare a root tagged type, and some associated primitive operations.--      Extend the root type, and override one or more primitive operations, --      inheriting the other primitive operations from the root type.--      Derive from the extended type, again overriding some primitive--      operations and inheriting others (including some that the parent --      inherited).--      Define a subprogram with a class-wide parameter, inside of which is a --      call on a dispatching primitive operation.  These primitive operations--      modify global variables (the class-wide parameter has mode IN).--     --     --     -- The following hierarchy of tagged types and primitive operations is -- utilized in this test:----    type Bank_Account (root)--            |--            | Operations--            |   Increment_Bank_Reserve--            |   Assign_Representative--            |   Increment_Counters--            |   Open--            |--    type Savings_Account (extended from Bank_Account)--            |--            | Operations--            |   (Increment_Bank_Reserve) (inherited)--            |   Assign_Representative    (overridden)--            |   Increment_Counters       (overridden)--            |   Open                     (overridden)--            |--    type Preferred_Account (extended from Savings_Account)--            |--            | Operations--            |   (Increment_Bank_Reserve) (inherited twice - Bank_Acct.)--            |   (Assign_Representative)  (inherited - Savings_Acct.)--            |   Increment_Counters       (overridden)--            |   Open                     (overridden)-- ---- In this test, we are concerned with the following selection of dispatching-- calls, accomplished with the use of a Bank_Account'Class IN procedure -- parameter :----                       \ Type--               Prim. Op \  Bank_Account  Savings_Account Preferred_Account--                         \------------------------------------------------ --   Increment_Bank_Reserve|      X                               X--   Assign_Representative |                      X--   Increment_Counters    |      X               X               X-------- The location of the declaration and derivation of the root and extended-- types will be varied over a series of tests.  Locations of declaration-- and derivation for a particular test are marked with an asterisk (*).---- Root type:--       --    *  Declared in package.--       Declared in generic package.---- Extended types:----       Derived in parent location.--    *  Derived in a nested package.--       Derived in a nested subprogram.--       Derived in a nested generic package.--       Derived in a separate package.--       Derived in a separate visible child package.--       Derived in a separate private child package.---- Primitive Operations:----    *  Procedures with same parameter profile.--       Procedures with different parameter profile.--    *  Functions with same parameter profile.--       Functions with different parameter profile.--    *  Mixture of Procedures and Functions.------ CHANGE HISTORY:--      06 Dec 94   SAIC    ACVC 2.0----!   with Report;  procedure C392003 is        --       -- Types and subtypes.       --        type Dollar_Amount  is new float;       type Interest_Rate  is delta 0.001 range 0.000 .. 1.000;       type Account_Types  is (Bank, Savings, Preferred, Total);       type Account_Counter is array (Account_Types) of integer;       type Account_Rep is (President, Manager, New_Account_Manager, Teller);        --       -- Constants.       --        Opening_Balance           : constant Dollar_Amount := 100.00;       Current_Rate              : constant Interest_Rate := 0.030;       Preferred_Minimum_Balance : constant Dollar_Amount := 1000.00;        --       -- Global Variables       --        Bank_Reserve         : Dollar_Amount   := 0.00;       Daily_Representative : Account_Rep     := New_Account_Manager;       Number_Of_Accounts   : Account_Counter := (Bank      => 0,                                                  Savings   => 0,                                                  Preferred => 0,                                                  Total     => 0);     -- Root tagged type and primitive operations declared in internal     -- package (Accounts).    -- Extended types (and primitive operations) derived in nested packages.       --=================================================================--     package Accounts is        --       -- Root account type and primitive operations.       --        -- Root type.        type Bank_Account is tagged          record             Balance : Dollar_Amount;          end record;        -- Primitive operations of Bank_Account.        function  Increment_Bank_Reserve (Acct : in     Bank_Account)          return Dollar_Amount;       function Assign_Representative   (Acct : in     Bank_Account)         return Account_Rep;       procedure Increment_Counters     (Acct : in     Bank_Account);       procedure Open                   (Acct : in out Bank_Account);       --=================================================================--                                  package S_And_L is            -- Declare extended type in a nested package.           type Savings_Account is new Bank_Account with          record             Rate : Interest_Rate;          end record;           -- Function Increment_Bank_Reserve inherited from           -- parent (Bank_Account).           -- Primitive operations (Overridden).          function Assign_Representative (Acct : in     Savings_Account)            return Account_Rep;          procedure Increment_Counters   (Acct : in     Savings_Account);          procedure Open                 (Acct : in out Savings_Account);                                  --=================================================================--                                     package Premium is               -- Declare further extended type in a nested package.              type Preferred_Account is new Savings_Account with             record                Minimum_Balance : Dollar_Amount;             end record;              -- Function Increment_Bank_Reserve inherited twice.             -- Function Assign_Representative inherited from parent              --   (Savings_Account).              -- Primitive operation (Overridden).             procedure Increment_Counters (Acct : in     Preferred_Account);             procedure Open               (Acct : in out Preferred_Account);              -- Function used to verify Open operation for Preferred_Account              -- objects.             function Verify_Open (Acct : in Preferred_Account) return Boolean;           end Premium; 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?