diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.java b/app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.java deleted file mode 100644 index fe5a2f6..0000000 --- a/app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.wbrawner.simplemarkdown.model; - -import eu.crydee.syllablecounter.SyllableCounter; - -public class Sentence { - - private String sentence = ""; - private int start = 0; - private int end = 0; - - private final static SyllableCounter sc = new SyllableCounter(); - - public Sentence(String content, int start, int end){ - this.start = start; - this.end = end; - this.sentence = content.substring(start, end); - - trimStart(); - } - - public Sentence(String sentence){ - this.sentence = sentence; - } - - private void trimStart() { - while(sentence.startsWith(" ")){ - this.start++; - sentence = sentence.substring(1); - } - } - - @Override - public String toString() { - return sentence; - } - - public int start(){ - return start; - } - - public int end(){ - return end; - } - - public int syllableCount(){ - return sc.count(sentence); - } -} diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.kt b/app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.kt new file mode 100644 index 0000000..8cce10d --- /dev/null +++ b/app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.kt @@ -0,0 +1,36 @@ +package com.wbrawner.simplemarkdown.model + +import eu.crydee.syllablecounter.SyllableCounter + +class Sentence(content: String, private var start: Int = 0, private val end: Int = 0) { + + private var sentence = content.substring(start, end) + private val sc = SyllableCounter() + + init { + trimStart() + } + + private fun trimStart() { + while (sentence.startsWith(" ")) { + this.start++ + sentence = sentence.substring(1) + } + } + + override fun toString(): String { + return sentence + } + + fun start(): Int { + return start + } + + fun end(): Int { + return end + } + + fun syllableCount(): Int { + return sc.count(sentence) + } +}