mirror of
https://github.com/ZhigalskiiIvan/TextStatisticsProject.git
synced 2024-12-22 21:01:52 +03:00
deleted unnecessary classes
This commit is contained in:
parent
a8b42a7d42
commit
ea792a3d0d
@ -6,10 +6,6 @@ import org.jetbrains.letsPlot.geom.*
|
||||
import kotlin.reflect.typeOf
|
||||
|
||||
|
||||
/** Gives statistics of saved texts.
|
||||
*/
|
||||
class StatisticBuilder {
|
||||
|
||||
/** Recognizes the name of the text, which
|
||||
* user want to see statistics about and type of output.
|
||||
* It calls methods of graphic building or printing data in console,
|
||||
@ -103,12 +99,8 @@ class StatisticBuilder {
|
||||
println("-".repeat(sectionTitle.length))
|
||||
println("Done!\n")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Used for reading text from a file or console. */
|
||||
class TextReader {
|
||||
|
||||
/** Asks the user which where they want to read the text from and
|
||||
* calls special for file- and console- reading methods according the answer.
|
||||
*/
|
||||
@ -125,7 +117,6 @@ class TextReader {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Read from console the name of text, checks that it hasn't saved yet and its contents,
|
||||
* asks if entered text is not correct and re-calls itself or
|
||||
* calls method of adding received text to data.
|
||||
@ -216,7 +207,6 @@ class TextReader {
|
||||
private fun addTextToData(textData: TextData, textName: String, content: String) =
|
||||
textData.addNewText(textName, content)
|
||||
|
||||
}
|
||||
|
||||
/** Stores data about tracking texts,
|
||||
* includes methods for work with them due the adding.
|
||||
@ -226,7 +216,6 @@ class TextData {
|
||||
/** list of monitored texts. */
|
||||
private val textsList = mutableListOf<Text>()
|
||||
|
||||
|
||||
fun haveText(): Boolean = textsList.isNotEmpty()
|
||||
|
||||
/** Method for removing text from watch list. Asks for a name of a text
|
||||
@ -234,7 +223,6 @@ class TextData {
|
||||
*/
|
||||
fun removeText() {
|
||||
|
||||
|
||||
if (!haveText()) {
|
||||
println("No saved texts")
|
||||
return
|
||||
@ -365,13 +353,11 @@ fun exit(): Nothing {
|
||||
*/
|
||||
class CommandCenter(
|
||||
private val textData: TextData,
|
||||
private val textReader: TextReader,
|
||||
private val statisticBuilder: StatisticBuilder
|
||||
) {
|
||||
|
||||
private val exitCommand = Command("exit", ::exit)
|
||||
private val addCommand = Command("add text") { textReader.readNewText(textData) }
|
||||
private val showStatisticsCommand = Command("show statistics") { statisticBuilder.getStatistics(textData) }
|
||||
private val addCommand = Command("add text") { readNewText(textData) }
|
||||
private val showStatisticsCommand = Command("show statistics") { getStatistics(textData) }
|
||||
private val removeTextCommand = Command("remove text") { textData.removeText() }
|
||||
|
||||
private val commandsList = listOf(exitCommand, addCommand, showStatisticsCommand, removeTextCommand)
|
||||
@ -531,13 +517,12 @@ class ReturnCommand : InputOutcomeCommand {
|
||||
override val exe: () -> Unit = throw ReturnException()
|
||||
}
|
||||
|
||||
|
||||
fun main() {
|
||||
|
||||
val textData = TextData()
|
||||
val statisticBuilder = StatisticBuilder()
|
||||
val textReader = TextReader()
|
||||
|
||||
val commandCenter = CommandCenter(textData, textReader, statisticBuilder)
|
||||
val commandCenter = CommandCenter(textData)
|
||||
|
||||
workCycle(commandCenter)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user