6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

COBOLで湯婆婆を…

Last updated at Posted at 2020-11-16

#n番煎じ
乗るしかないこのビッグウェーブに

@NemesisさんのJavaで湯婆婆を実装してみるが面白かったのでCOBOLでやってみました。

YUBABA.COB
000010******************************************************************
000020*  湯婆婆                                                        *
000030******************************************************************
000040 IDENTIFICATION             DIVISION.
000050 PROGRAM-ID.                YUBABA.
000060 AUTHOR.                    MOSAKU ANCH.
000070 DATE-WRITTEN.              2020/11/16.
000080*
000090 ENVIRONMENT                DIVISION.
000100 CONFIGURATION              SECTION.
000110 SOURCE-COMPUTER.           FACOM-V-830.
000120 OBJECT-COMPUTER.           FACOM-V-830.
000130*
000140 INPUT-OUTPUT               SECTION.
000150 FILE-CONTROL.
000160*
000170 DATA         DIVISION.
000180 FILE         SECTION.
000190*
000200 WORKING-STORAGE  SECTION.
000210 01  FULLNAME         PIC X(20) VALUE SPACE.
000220 01  FULLNAME2.
000230   03  FULLNAME3      OCCURS 20.
000240     05  NAME         PIC X(1) VALUE SPACE.
000250 77  NEWNAME          PIC X(1) VALUE SPACE.
000260 77  RANSU            PIC 9(2) VALUE ZERO.
000270 01  JIKAN.
000280   03  HH             PIC 9(2) VALUE ZERO.
000290   03  MM             PIC 9(2) VALUE ZERO.
000300   03  SS             PIC 9(2) VALUE ZERO.
000310   03  TT             PIC 9(2) VALUE ZERO.
000320 77  SYURYOCNT        PIC 9(3) VALUE ZERO.
000330*
000340 PROCEDURE               DIVISION.
000350 HAJIME                 SECTION.
000360     PERFORM KIMEI.
000370*
000380     PERFORM MEIMEI UNTIL  NEWNAME  NOT =   SPACE.
000390*
000400     PERFORM OWARI.
000410     EXIT.
000420*
000430 KIMEI               SECTION.
000440     DISPLAY "契約書だよ。そこに名前を書きな。".
000450     ACCEPT  FULLNAME FROM     CONSOLE.
000480     DISPLAY "フン。" FULLNAME "というのかい。贅沢な名だねぇ。".
000490     MOVE   FULLNAME  TO          FULLNAME2.
000500     EXIT.
000510*    
000520 MEIMEI              SECTION.
000530     ACCEPT  JIKAN    FROM     TIME.
000540     COMPUTE RANSU    = (HH + MM + SS + TT).
000550     PERFORM UNTIL RANSU < 21
000560             COMPUTE RANSU    =  RANSU - 20
000570     END-PERFORM.
000580     IF NAME(RANSU) NOT = SPACE
000590       MOVE    NAME(RANSU) TO NEWNAME
000600     END-IF.
000610     ADD     1           TO SYURYOCNT.
000620     IF SYURYOCNT > 100
000630        MOVE 4081        TO RETURN-CODE
000640        STOP RUN
000650     END-IF.
000660     EXIT.
000670*
000680 OWARI                  SECTION.
000690     DISPLAY "今からお前の名前は" NEWNAME "だ。いいかい、" 
000691          NEWNAME "だよ。分かったら返事をするんだ、" NEWNAME "!!".
000700     STOP RUN.
000710     ENDCOBOL.
000720

説明はニーズがなさそうなので割愛。
もちろん全角入力は対応しておりません。

契約書だよ。そこに名前を書きな。
MOSAKU ANCHU

フン。MOSAKU ANCHU        というのかい。贅沢な名だねぇ。

今からお前の名前はMだ。いいかい、Mだよ。分かったら返事をするんだ、M!!

Mになりました。

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?