Skip to content
Snippets Groups Projects
Commit 47984fab authored by reblochor's avatar reblochor
Browse files

Fixed bug, added list.clone extension for the Deck questions, removed scope...

Fixed bug, added list.clone extension for the Deck questions, removed scope functions from solutions
parent 947e0a96
No related branches found
No related tags found
No related merge requests found
......@@ -40,10 +40,7 @@ open class Card(var isFaceUp: Boolean, var cardValue: CardValue) {
private val stringRepresentation: String
get() = if (isFaceUp) "$colorConsole${if(cardValue != CardValue.TEN) " " else ""}${cardValue}$symbol$COLOR_RESET" else " **"
/**
* Abstract property representing the color the card will be printed in the console (constants defined in top of screen)
* TODO: make this attribute overrideable
*/
open val colorConsole: String = "IMPLEMENT Card#ColorConsole"
/**
......
package model
import clone
import java.util.*
import kotlin.math.min
......@@ -84,7 +85,9 @@ open class Deck(val cards: MutableList<Card> = mutableListOf()) {
* TODO: If expression
*/
fun addSingleCardAndReturnNewDeck(card: Card) = if(pileCompatibilityCheck(card)) {
Deck(cards.apply { add(card) })
val newCards = cards.clone()
newCards.add(card)
Deck(newCards)
}
else {
null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment