From e284c47e8917d913723e8c884f389caee887705e Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 9 Sep 2022 10:27:42 +0200 Subject: [PATCH] Add base for GnuCobol version --- COBOL/Gnu/.gitignore | 3 ++ COBOL/Gnu/GildedRose.cbl | 76 ++++++++++++++++++++++++++++++++++++++++ COBOL/Gnu/build.sh | 1 + COBOL/Gnu/run.sh | 2 ++ 4 files changed, 82 insertions(+) create mode 100644 COBOL/Gnu/.gitignore create mode 100644 COBOL/Gnu/GildedRose.cbl create mode 100755 COBOL/Gnu/build.sh create mode 100755 COBOL/Gnu/run.sh diff --git a/COBOL/Gnu/.gitignore b/COBOL/Gnu/.gitignore new file mode 100644 index 00000000..da658a72 --- /dev/null +++ b/COBOL/Gnu/.gitignore @@ -0,0 +1,3 @@ +in-items +items +GildedRose.so diff --git a/COBOL/Gnu/GildedRose.cbl b/COBOL/Gnu/GildedRose.cbl new file mode 100644 index 00000000..47e5c117 --- /dev/null +++ b/COBOL/Gnu/GildedRose.cbl @@ -0,0 +1,76 @@ +program-id. GildedRose as "GildedRose". + +environment division. + +input-output section. + +file-control. + select in-items assign 'in-items'. + select items assign 'items'. + +data division. +file section. + fd in-items. + 01 in-item pic x(58). + fd items. + 01 item. + 02 sell-in pic 9(4). + 02 quality pic 9(4). + 02 name pic x(50). + +working-storage section. +procedure division. + open input in-items output items. +start-lable. + read in-items end go to end-lable. + move in-item to item. + if name not equal "Aged Brie" and name not equal "Backstage passes to a TAFKAL80ETC concert" + if quality > 0 + if name not equal to "Sulfuras, Hand of Ragnaros" + compute quality = quality - 1 + end-if + end-if + else + if quality < 50 + compute quality = quality + 1 + if name equals "Backstage passes to a TAFKAL80ETC concert" + if sell-in < 11 + if quality < 50 + compute quality = quality + 1 + end-if + end-if + if sell-in < 6 + if quality < 50 + compute quality = quality + 1 + end-if + end-if + end-if + end-if + end-if + if name not equal "Sulfuras, Hand of Ragnaros" + compute sell-in = sell-in - 1 + end-if + if sell-in < 0 + if name is not equal to "Aged Brie" + if name is not equal to "Backstage passes to a TAFKAL80ETC concert" + if quality > 0 + if name is equal to "Sulfuras, Hand of Ragnaros" + compute quality = quality - 1 + end-if + end-if + else + compute quality = quality - quality + end-if + else + if quality < 50 + compute quality = quality + 1 + end-if + end-if + end-if + write item. + go to start-lable. +end-lable. + close items. +goback. + +end program GildedRose. diff --git a/COBOL/Gnu/build.sh b/COBOL/Gnu/build.sh new file mode 100755 index 00000000..1632b7c3 --- /dev/null +++ b/COBOL/Gnu/build.sh @@ -0,0 +1 @@ +cobc --free --std=mf -O GildedRose.cbl diff --git a/COBOL/Gnu/run.sh b/COBOL/Gnu/run.sh new file mode 100755 index 00000000..3201dadf --- /dev/null +++ b/COBOL/Gnu/run.sh @@ -0,0 +1,2 @@ +touch in-items +cobcrun GildedRose