From 3fe3cdec68f6cb53108ceab691f9d97d5405dd84 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sat, 17 Aug 2019 13:31:13 -0500 Subject: [PATCH] Convert Sentence to Kotlin --- .../simplemarkdown/model/Sentence.java | 48 ------------------- .../wbrawner/simplemarkdown/model/Sentence.kt | 36 ++++++++++++++ 2 files changed, 36 insertions(+), 48 deletions(-) delete mode 100644 app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.java create mode 100644 app/src/main/java/com/wbrawner/simplemarkdown/model/Sentence.kt 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) + } +}