deleted unnecessary classes

This commit is contained in:
ZhigalskiiIvan 2023-03-30 22:00:19 +03:00
parent a8b42a7d42
commit ea792a3d0d

View File

@ -6,10 +6,6 @@ import org.jetbrains.letsPlot.geom.*
import kotlin.reflect.typeOf import kotlin.reflect.typeOf
/** Gives statistics of saved texts.
*/
class StatisticBuilder {
/** Recognizes the name of the text, which /** Recognizes the name of the text, which
* user want to see statistics about and type of output. * user want to see statistics about and type of output.
* It calls methods of graphic building or printing data in console, * It calls methods of graphic building or printing data in console,
@ -103,12 +99,8 @@ class StatisticBuilder {
println("-".repeat(sectionTitle.length)) println("-".repeat(sectionTitle.length))
println("Done!\n") 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 /** Asks the user which where they want to read the text from and
* calls special for file- and console- reading methods according the answer. * 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, /** 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 * asks if entered text is not correct and re-calls itself or
* calls method of adding received text to data. * calls method of adding received text to data.
@ -216,7 +207,6 @@ class TextReader {
private fun addTextToData(textData: TextData, textName: String, content: String) = private fun addTextToData(textData: TextData, textName: String, content: String) =
textData.addNewText(textName, content) textData.addNewText(textName, content)
}
/** Stores data about tracking texts, /** Stores data about tracking texts,
* includes methods for work with them due the adding. * includes methods for work with them due the adding.
@ -226,7 +216,6 @@ class TextData {
/** list of monitored texts. */ /** list of monitored texts. */
private val textsList = mutableListOf<Text>() private val textsList = mutableListOf<Text>()
fun haveText(): Boolean = textsList.isNotEmpty() fun haveText(): Boolean = textsList.isNotEmpty()
/** Method for removing text from watch list. Asks for a name of a text /** Method for removing text from watch list. Asks for a name of a text
@ -234,7 +223,6 @@ class TextData {
*/ */
fun removeText() { fun removeText() {
if (!haveText()) { if (!haveText()) {
println("No saved texts") println("No saved texts")
return return
@ -365,13 +353,11 @@ fun exit(): Nothing {
*/ */
class CommandCenter( class CommandCenter(
private val textData: TextData, private val textData: TextData,
private val textReader: TextReader,
private val statisticBuilder: StatisticBuilder
) { ) {
private val exitCommand = Command("exit", ::exit) private val exitCommand = Command("exit", ::exit)
private val addCommand = Command("add text") { textReader.readNewText(textData) } private val addCommand = Command("add text") { readNewText(textData) }
private val showStatisticsCommand = Command("show statistics") { statisticBuilder.getStatistics(textData) } private val showStatisticsCommand = Command("show statistics") { getStatistics(textData) }
private val removeTextCommand = Command("remove text") { textData.removeText() } private val removeTextCommand = Command("remove text") { textData.removeText() }
private val commandsList = listOf(exitCommand, addCommand, showStatisticsCommand, removeTextCommand) private val commandsList = listOf(exitCommand, addCommand, showStatisticsCommand, removeTextCommand)
@ -531,13 +517,12 @@ class ReturnCommand : InputOutcomeCommand {
override val exe: () -> Unit = throw ReturnException() override val exe: () -> Unit = throw ReturnException()
} }
fun main() { fun main() {
val textData = TextData() val textData = TextData()
val statisticBuilder = StatisticBuilder()
val textReader = TextReader()
val commandCenter = CommandCenter(textData, textReader, statisticBuilder) val commandCenter = CommandCenter(textData)
workCycle(commandCenter) workCycle(commandCenter)
} }