From 4f4d0243a0865f44312ab123952352792275b287 Mon Sep 17 00:00:00 2001 From: Denys Date: Sun, 11 May 2025 00:05:22 +1200 Subject: [PATCH] ItemRepository Separate Data from main func --- .../kotlin/com/gildedrose/TexttestFixture.kt | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Kotlin/src/main/kotlin/com/gildedrose/TexttestFixture.kt b/Kotlin/src/main/kotlin/com/gildedrose/TexttestFixture.kt index 58c2db75..57c95ca5 100644 --- a/Kotlin/src/main/kotlin/com/gildedrose/TexttestFixture.kt +++ b/Kotlin/src/main/kotlin/com/gildedrose/TexttestFixture.kt @@ -1,24 +1,26 @@ package com.gildedrose +object ItemRepository { + val items = listOf( + Item("+5 Dexterity Vest", 10, 20), // + Item("Aged Brie", 2, 0), // + Item("Elixir of the Mongoose", 5, 7), // + Item("Sulfuras, Hand of Ragnaros", 0, 80), // + Item("Sulfuras, Hand of Ragnaros", -1, 80), + Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), + Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), + Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), + // this conjured item does not work properly yet + Item("Conjured Mana Cake", 3, 6) + ) +} + //asd fun main(args: Array) { println("OMGHAI!") - val items = listOf( - Item("+5 Dexterity Vest", 10, 20), // - Item("Aged Brie", 2, 0), // - Item("Elixir of the Mongoose", 5, 7), // - Item("Sulfuras, Hand of Ragnaros", 0, 80), // - Item("Sulfuras, Hand of Ragnaros", -1, 80), - Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), - Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), - Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), - // this conjured item does not work properly yet - Item("Conjured Mana Cake", 3, 6) - ) - - val app = GildedRose(items) + val app = GildedRose(ItemRepository.items) var days = 2 if (args.size > 0) { @@ -28,7 +30,7 @@ fun main(args: Array) { for (i in 0..days - 1) { println("-------- day $i --------") println("name, sellIn, quality") - for (item in items) { + for (item in app.items) { println("${item.name}, ${item.sellIn}, ${item.quality}") } println()