      $set mfoo ooctrl(+n)
      ************************************************************************
      * 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.
      ************************************************************************
       class-id. CheckAccount
              data is protected
              inherits from Account with data.


        object section.
        class-control.
           Account is class "account"
           CheckAccount is class "caccount"
           ExceptionManager is class "exptnmgr"
           .
       working-storage section.
           copy "accinfo.cpy".
       class-object.
       object-storage section.
      *------------------------------------------------------------
      * Set the first account number for Check accounts.
      *------------------------------------------------------------
       Method-id. "getFirstAccountNumber".

       linkage section.
           01  lnkNumber               pic 9(8).
       procedure division returning lnkNumber.
      *----C0001. Set up account numbering for checking accounts.
           move 10000000 to lnkNumber
           exit method.
       end method "getFirstAccountNumber".
       end class-object.
       Object.
       object-storage section.

           01  permittedOverdraft          pic S9(10)v99 comp-5 value 0.

      *------------------------------------------------------------
      * Implementation of "withdraw" which allows for overdrafts.
      *------------------------------------------------------------

       method-id. "withdraw".

       local-storage section.
           01 workingValue         pic S9(10)v99.
           01 lsErrorNumber        pic x(4) comp-5.
           01 lsErrorObject        object reference.
       linkage section.
           01 lsAmount             pic 9(10)v99.

       procedure division using lsAmount.
      *----C010. Withdraw lsAmount from this account
           subtract lsAmount from balance giving workingValue
           if workingValue < permittedOverdraft
               invoke ExceptionManager "queryMessageFile"
                                       using "bank" "account"
                                   returning lsErrorNumber
               add debitExceedsOverdraft to lsErrorNumber
               invoke self "raiseException" using lsErrorNumber
                                        returning lsErrorObject

           else
               move workingValue to balance
           end-if
          exit method.
       end method "withdraw".

      *------------------------------------------------------------
      * Sets an overdraft limit for this account.
      *------------------------------------------------------------
       method-id. "setOverdraft".

       linkage section.
           01 lsOverdraft          pic S9(10)v99.

       procedure division using lsOverdraft.
      *----C020. Set the overdraft.
           move lsOverdraft to permittedOverdraft
           exit method.
       end method "setOverdraft".

      *------------------------------------------------------------
      * Dummy code pretending to print a statement
      *------------------------------------------------------------

       method-id. "printStatement".
       local-storage section.
           01  displayBalance       pic -(9)9.99.


       procedure division.
      *----C040. Print a statement.
           display "Check Account"
           display "Name:     " aName
           move balance to displayBalance
           display "Balance : " displayBalance
           exit method.
       end method "printStatement".

      *-----------------------------------------------------------------
      * Return the type of account.
      *-----------------------------------------------------------------
       method-id. "getType".

       linkage section.
           01  lsType          pic x(accTypeLength).

       procedure division returning lsType.
      *----C050. Return the account atype.
           move spaces to lsType
           move checkType to lsType
           exit method.
       end method "getType".
       end object.
       end class CheckAccount.
