      $set mfoo ooctrl(+n)
      ************************************************************************
      * Copyright (C) 1991-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. SavingsAccount data is protected
                          inherits from Account with data.

        object section.
        class-control.
           SavingsAccount is class "saccount"
           Account is class "account"
           .
       working-storage section.
           copy "accinfo.cpy".
       class-object.
       object-storage section.

       01 rate     pic 99v99 comp-5.

      *------------------------------------------------------------
      * Initialize nextAccountNumber and the rate of interest.
      * This is the class procedure division, which only gets
      * executed once.
      *------------------------------------------------------------
      *------------------------------------------------------------
      * Return the interest rate of this type of account
      *------------------------------------------------------------
       Method-id. "getRate".

       linkage section.
           01 lnkRate      pic 99v99 comp.
       procedure division returning lnkRate.
           move 8.3 to lnkRate
           exit method.
       end method "getRate".
      *------------------------------------------------------------
      * Set the first account number for savings accounts.
      *------------------------------------------------------------
       Method-id. "getFirstAccountNumber".

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

           01 interest             pic 9(8)v99.

      *------------------------------------------------------------
      * PRIVATE. Add interest to this account.
      *------------------------------------------------------------

       method-id. "addInterest".

       local-storage section.
           01  rate            pic 99v99 comp.

       procedure division.
      *----S010. Calculate the interest
           invoke selfclass "getRate" returning rate
           compute interest rounded = (balance * rate)  / 100
           add interest to balance
           exit method.
       end method "addinterest".

      *------------------------------------------------------------
      * Adds interest if none has been added since this charge
      * period started, In a real application this would be linked to
      * the date in some way.
      *------------------------------------------------------------
       method-id. "updateBalance".
       local-storage section.

           procedure division.
      *----S020. Check the charge period.
           if newPeriod
      *---------S021. Add the interest and reset the newPeriod flag.
               invoke self "addInterest"
               set chargesApplied to true
           end-if
           exit method.
       end method "updateBalance".

      *------------------------------------------------------------
      * Print a statement to the display
      *------------------------------------------------------------

       method-id. "printStatement".
       local-storage section.

           01  displayBalance       pic -(9)9.99.

       procedure division.
      *----S030. Print a statement.
           display "Savings Account"
           invoke self "updateBalance"
           display "Name:          " aName
           move balance to displayBalance
           display "Balance:       " displayBalance
           move interest to displayBalance
           display "Interest paid: " displayBalance
           exit method.
       end method "printStatement".
      *-----------------------------------------------------------------
      * Return the type of account.
      *-----------------------------------------------------------------
       method-id. "getType".

       linkage section.
           01  lsType          pic x(10).

       procedure division returning lsType.
      *----S040. Return the account type.
           move spaces to lsType
           move savingstype to lsType
           exit method.
       end method "getType".

       end object.
       end class SavingsAccount.
