home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / winestr / userint.cbl < prev    next >
Text File  |  1997-03-22  |  9KB  |  229 lines

  1.       * --------------------------------------------- *
  2.       *  USERINT.CBL
  3.       *     User interface class for the wine store sample.
  4.       *     Version 2
  5.       * --------------------------------------------- *
  6.  
  7.        IDENTIFICATION Division.
  8.        CLASS-ID. "UserInterface" inherits SOMObject.
  9.  
  10.        ENVIRONMENT DIVISION.
  11.        Configuration Section.
  12.        Repository.
  13.             CLASS SOMObject is "SOMObject".
  14.  
  15.        DATA DIVISION.
  16.        Working-Storage Section.
  17.        01   User-Action                PIC X(10).
  18.            88  UA-Add                      Value "ADD".
  19.            88  UA-Delete                   Value "DELETE".
  20.            88  UA-End                      Value "END".
  21.  
  22.        PROCEDURE DIVISION.
  23.  
  24.       * ========================================
  25.       * ========================================
  26.        IDENTIFICATION DIVISION.
  27.        Method-Id. "WriteWelcome".
  28.        DATA DIVISION.
  29.        Working-Storage Section.
  30.  
  31.        PROCEDURE DIVISION.
  32.            Display "===========================================".
  33.            Display "===                        o            ===".
  34.            Display "===                 o                   ===".
  35.            Display "===             o      o  o             ===".
  36.            Display "===         -----o----o-----            ===".
  37.            Display "===          \ o    o  o  /             ===".
  38.            Display "===            \~~~~~~~~/               ===".
  39.            Display "===              \    /                 ===".
  40.            Display "===                \/                   ===".
  41.            Display "===                ||                   ===".
  42.            Display "===                ||                   ===".
  43.            Display "===             ___||___                ===".
  44.            Display "===                                     ===".
  45.            Display "===           Welcome to                ===".
  46.            Display "===     Jim n'Bob's Wine Shoppe         ===".
  47.            Display "===         --------------              ===".
  48.            Display "===                                     ===".
  49.            Display "===   We appreciate your busness.       ===".
  50.            Display "===   Please fill out your order.       ===".
  51.            Display "===                                     ===".
  52.            Display "===========================================".
  53.            Display " ".
  54.            Exit Method.
  55.        End Method "WriteWelcome".
  56.  
  57.       * ========================================
  58.       * ========================================
  59.        IDENTIFICATION DIVISION.
  60.        Method-Id. "ReadAction".
  61.        DATA DIVISION.
  62.        Working-Storage Section.
  63.        01  WS-Edit-Flag                PIC X.
  64.        01  Answer                      PIC 9.
  65.        Linkage Section.
  66.        01  LS-Action                   PIC X(10).
  67.  
  68.        PROCEDURE DIVISION
  69.                    Returning LS-Action.
  70.            Move Low-Value to WS-Edit-Flag.
  71.            Perform Until WS-Edit-Flag Not = Low-Value
  72.               Move 0 to Answer
  73.               Display "      ============================="
  74.               Display "      |       Order Menu          |"
  75.               Display "      |                           | "
  76.               Display "      |   1. Add a bottle         | "
  77.               Display "      |   2. Delete a bottle      | "
  78.               Display "      |   9. End                  | "
  79.               Display "      ============================= "
  80.               Display " Enter an action.... "
  81.               Accept Answer from SYSIN
  82.               Evaluate Answer
  83.                  When 1
  84.                     Set UA-Add to TRUE
  85.                     Move High-Value to WS-Edit-Flag
  86.                  When 2
  87.                     Set UA-Delete to TRUE
  88.                     Move High-Value to WS-Edit-Flag
  89.                  When 9
  90.                     Set UA-End to TRUE
  91.                     Move High-Value to WS-Edit-Flag
  92.               End-Evaluate
  93.               Move User-Action to LS-Action
  94.            End-perform.
  95.            Exit Method.
  96.        End Method "ReadAction".
  97.  
  98.       * ========================================
  99.       * ========================================
  100.        IDENTIFICATION DIVISION.
  101.        Method-Id. "ReadType".
  102.        DATA DIVISION.
  103.        Working-Storage Section.
  104.        01  WS-Type                     PIC X(80).
  105.        Linkage Section.
  106.        01  LS-Type                     PIC X(20).
  107.  
  108.        PROCEDURE DIVISION
  109.                    Returning LS-Type.
  110.            Initialize WS-Type.
  111.            Display " ".
  112.            Display "  ====================================".
  113.            Display " ".
  114.            Display "   Enter the type of wine: ".
  115.            Accept WS-Type from SYSIN.
  116.            Move WS-Type(1:20) to LS-Type.
  117.            Exit Method.
  118.        End Method "ReadType".
  119.  
  120.       * ========================================
  121.       * ========================================
  122.        IDENTIFICATION DIVISION.
  123.        Method-Id. "ReadCost".
  124.        DATA DIVISION.
  125.        Working-Storage Section.
  126.        01  WS-Cost                     PIC X(6).
  127.        Linkage Section.
  128.        01  LS-Cost                     PIC 9(3)V99.
  129.  
  130.        PROCEDURE DIVISION
  131.                    Returning LS-Cost.
  132.            Initialize WS-Cost.
  133.            Display " ".
  134.            Display "   Enter the cost: ".
  135.            Accept WS-Cost from SYSIN.
  136.            Compute LS-Cost = Function Numval-c(WS-Cost).
  137.            Exit Method.
  138.        End Method "ReadCost".
  139.  
  140.       * ========================================
  141.       * ========================================
  142.        IDENTIFICATION DIVISION.
  143.        Method-Id. "WriteMessage".
  144.        DATA DIVISION.
  145.        Linkage Section.
  146.        01  LS-Flag                     PIC X.
  147.  
  148.        PROCEDURE DIVISION
  149.                    Using LS-Flag.
  150.            If LS-Flag = 0
  151.               Display  "     "
  152.                    User-Action " successfully completed "
  153.            Else
  154.               Display  "     "
  155.                    User-Action " not successful, too bad... "
  156.            End-If.
  157.            Display " ".
  158.            Exit Method.
  159.        End Method "WriteMessage".
  160.  
  161.  
  162.       * ========================================
  163.       * ========================================
  164.        IDENTIFICATION DIVISION.
  165.        Method-Id. "WriteOutput".
  166.        DATA DIVISION.
  167.        Working-Storage Section.
  168.        01  Formatted-Cost              PIC $Z,ZZZ,ZZ9.99.
  169.        Linkage Section.
  170.        01  Total-Cost                  PIC 9(7)V99.
  171.        01  Order-Number                PIC 9(5).
  172.        01  Order-Date                  PIC X(10).
  173.  
  174.        PROCEDURE DIVISION
  175.                    Using Total-Cost Order-Number Order-Date.
  176.            Move Total-Cost to Formatted-Cost.
  177.            Display " ".
  178.            Display "     Thank you for your order.... ".
  179.            Display " ".
  180.            Display "  ====================================".
  181.            Display "         Order Information ".
  182.            Display " ".
  183.            Display "   Your order number: " Order-Number.
  184.            Display "   Date: " Order-Date.
  185.            Display " ".
  186.            Display "   Total cost: " Formatted-Cost.
  187.            Display "   Contents: ".
  188.            Exit Method.
  189.        End Method "WriteOutput".
  190.  
  191.       * ========================================
  192.       * ========================================
  193.        IDENTIFICATION DIVISION.
  194.        Method-Id. "WriteBottle".
  195.        DATA DIVISION.
  196.        Working-Storage Section.
  197.        01  WS-Formatted-Cost           PIC ZZ9.99.
  198.        01  WS-Index                    PIC 9(2).
  199.        01  WS-Formatted-Index          PIC Z9.
  200.        Linkage Section.
  201.        01  LS-Items.
  202.            05 LS-Count                 PIC 9(4).
  203.            05 LS-Item    Occurs 1 to 64 times
  204.                          Depending on LS-Count
  205.                          Indexed by LS-Index.
  206.               10 LS-Type               PIC X(20).
  207.               10 LS-Cost               PIC 9(3)V99.
  208.  
  209.        PROCEDURE DIVISION
  210.                    Using LS-Items.
  211.            Move 0 to WS-Index.
  212.            Display "   ------------------------------------------   ".
  213.            Perform Varying LS-Index from 1 by 1
  214.                      Until LS-Index > LS-Count
  215.               Move LS-Cost(LS-Index) to WS-Formatted-Cost
  216.               Add 1 to WS-Index
  217.               Move WS-Index to WS-Formatted-Index
  218.               Display "    "  WS-Formatted-Index ". "
  219.                       LS-Type(LS-Index) " at " WS-Formatted-Cost
  220.            End-Perform
  221.            Display "   ------------------------------------------   ".
  222.            Exit Method.
  223.        End Method "WriteBottle".
  224.  
  225.       *---------------------------------
  226.        END CLASS "UserInterface".
  227.  
  228.  
  229.