package mg.dot.feufaro.solfa

class Note (val note: String, private var separator: String= "") {

    var marker: MutableList<String> = mutableListOf()
    var markerBefore: String = ""
    fun addMarker(newMarker: String) {
        if (marker.contains(newMarker)) return
        marker.add(newMarker)
    }
    fun setMarkers(newMarkers: MutableList<String>) {
        marker = newMarkers
    }
    fun hasMarker(symbol: String): Boolean {
        return marker.contains(symbol)
    }
    fun markBefore(newMarker: String) {
        markerBefore += newMarker
    }
    /*fun unMark(badMarker: String) {
        if (marker.contains(badMarker)) {
            marker.remove(badMarker)
        }
    }
    fun setSeparator(newSeparator : String) {
        separator = newSeparator
    }*/
    private fun String.asMarker(): String {
        if (this == "(") return ""
        if (this == ",") return " ,"
        return this
    }
    override fun toString(): String {
        var result = ""
        if (marker.contains("(")) {
            result += "("
        }
        result += markerBefore.toCharArray().joinToString("") { it.toString().asMarker() } + note + marker.joinToString(""){ it.asMarker() }
        return result
    }
}