      $set mfoo

      ************************************************************************
      * Copyright (C) 1996-1999 Micro Focus International Ltd.
      * All rights reserved.
      *  
      * This demonstration program is provided for use by users of 
      * Micro Focus products (the "Software") and may be used, 
      * modified and distributed as part of your application provided 
      * that you properly acknowledge the copyright of Micro Focus in this
      * material.
      *     
      * All conditions, warranties and undertakings, express or implied, 
      * statutory or otherwise, on the part of Micro Focus are excluded, 
      * including without limitation those of merchantability or fitness  
      * for purpose. This shall not, however, purport to exclude or 
      * restrict the liability of Micro Focus to any extent not 
      * permitted by law.
      *
      * IN NO EVENT WILL MICRO FOCUS BE LIABLE FOR ANY INDIRECT, 
      * INCIDENTAL, SPECIAL, CONSEQUENTIAL OR OTHER DAMAGES ARISING OUT 
      * OF THE USE OF THE DEMONSTRATION PROGRAM DISTRIBUTED WITH THE 
      * SOFTWARE, WHETHER OR NOT INFORMED OF THE POSSIBILITIES OF 
      * DAMAGES IN ADVANCE.  THESE LIMITATIONS APPLY TO ALL CAUSES OF 
      * ACTION, INCLUDING BREACH OF CONTRACT, BREACH OF WARRANTY, STRICT
      * LIABILITY, AND ANY ACTIONS IN TORTS.
      *
      ************************************************************************
      *
      * Program to demonstrate inheritance by creating instances of
      * different sorts of Account class
      *
      ************************************************************************

       program-id. bank1.

        object section.
        class-control.
           Account is class "account"
           SavingsAccount is class "saccount"
           HighRateAccount is class "haccount"
           CheckAccount is class "caccount"
           .
       working-storage section.

      *----The first object is for CheckAccounts;
      *    the second for SavingsAccounts;
      *    the third for HighRateAccounts.
           01  anaccount  object reference.
           01  asaccount  object reference.
           01  ahaccount  object reference.
           01  acustomer  pic x(80).
           01  anamount   pic 9(10)v99.
           01  dispamount pic 9(5).99.

       procedure division.

       main section.
      *----B001. First we create a new account for Dan, with $100.
      *    We will use the term anAccount to refer to this account
           move "Dan" to aCustomer
           move 100 to anAmount

           invoke CheckAccount "OpenAccount" using aCustomer
                                              anAmount
                                    returning anAccount
      *----B002. Now we deposit an extra $1000 in the account
           move 1000 to anamount
           invoke anAccount "Deposit" using anAmount
      *----B003. Next we withdraw $50 from the account. So far all the
      *    code executed has been inherited from the Account class, but
      *    CheckAccount implements its own withdrawal method to check
      *    your overdraft facility.
           move 50 to anAmount
           invoke anAccount "Withdraw" using anAmount
      *----B004. Next we display the balance for this account.
           invoke anAccount "GetBalance" returning anAmount
           perform display-balance
      *----B004. Now we open a SavingsAccount. As before, much of the
      *    code is actually in the Account class.
           move "Chris" to acustomer
           move 500 to anamount
           invoke SavingsAccount "OpenAccount" using aCustomer
                                                     anAmount
                                           returning asAccount
      *----B005. Now we add interest to this account. This method is
      *    implemented in SavingsAccount.
           invoke asAccount "updateBalance"
      *----B006. Display the balance of the account.
           invoke asAccount "GetBalance" returning anAmount
           perform display-balance
      *----B007. Next we create a HighRateAccount. HighRateAccount
      *    implements its own version of OpenAccount to check that the
      *    customer has a sufficient opening balance.
           move "Mike" to aCustomer
           move 1005 to anAmount
           invoke HighRateAccount "openAccount" using aCustomer
                                                      anAmount
                                            returning ahAccount
      *----B008. Finally we print statements for all three types of
      *    account. All accounts respond to the "printStatement" method
      *    method with their own implementation.
           invoke anAccount "printStatement"
           invoke asAccount "printStatement"
           invoke ahAccount "printStatement"
           stop run.

       display-balance section.
      *----B010. Move the balance to a display variable and show it.
           move anamount to dispamount
           display dispamount.
