mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-09 11:41:37 +00:00
App class
This commit is contained in:
parent
d78d1ea7a2
commit
09f0f755eb
@ -2,26 +2,41 @@ package com.gildedrose
|
|||||||
|
|
||||||
import com.gildedrose.data.constants.ItemRepository
|
import com.gildedrose.data.constants.ItemRepository
|
||||||
|
|
||||||
|
class App(private val glidedRose: GildedRose) {
|
||||||
|
var days: Int = 2
|
||||||
|
|
||||||
|
fun printGlideRoseTable() {
|
||||||
|
welcomeMessage()
|
||||||
|
repeat(days) { day ->
|
||||||
|
printTableHeader(day)
|
||||||
|
for (item in glidedRose.items) {
|
||||||
|
println("${item.name}, ${item.sellIn}, ${item.quality}")
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
glidedRose.updateQuality()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun printTableHeader(day: Int) {
|
||||||
|
println("-------- day $day --------")
|
||||||
|
println("name, sellIn, quality")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun welcomeMessage() {
|
||||||
|
println("OMGHAI!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//asd
|
//asd
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
println("OMGHAI!")
|
val app = App(GildedRose(ItemRepository.items))
|
||||||
|
|
||||||
val app = GildedRose(ItemRepository.items)
|
|
||||||
|
|
||||||
var days = 2
|
var days = 2
|
||||||
if (args.size > 0) {
|
if (args.size > 0) {
|
||||||
days = Integer.parseInt(args[0]) + 1
|
days = Integer.parseInt(args[0]) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in 0..days - 1) {
|
app.days = days
|
||||||
println("-------- day $i --------")
|
app.printGlideRoseTable()
|
||||||
println("name, sellIn, quality")
|
|
||||||
for (item in app.items) {
|
|
||||||
println("${item.name}, ${item.sellIn}, ${item.quality}")
|
|
||||||
}
|
|
||||||
println()
|
|
||||||
app.updateQuality()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user