From a20f89d3bbad44f5fd178f71596370778b62cff9 Mon Sep 17 00:00:00 2001 From: SERYOGA-cloud Date: Tue, 24 Jun 2025 23:38:12 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=C2=AB=D0=97=D0=B0=D0=BC=D0=B5=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/Archive.kt | 3 ++ src/main/kotlin/Main.kt | 3 +- src/main/kotlin/Note.kt | 2 + src/main/kotlin/NotesApp.kt | 100 ++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/Archive.kt create mode 100644 src/main/kotlin/Note.kt create mode 100644 src/main/kotlin/NotesApp.kt diff --git a/src/main/kotlin/Archive.kt b/src/main/kotlin/Archive.kt new file mode 100644 index 00000000..b779fcf0 --- /dev/null +++ b/src/main/kotlin/Archive.kt @@ -0,0 +1,3 @@ +class Archive(val name: String) { + var noteList = mutableListOf() +} \ No newline at end of file diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index aade54c5..fd1cb1e5 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -1,3 +1,4 @@ fun main(args: Array) { - println("Hello World!") + val notesApp = NotesApp() + notesApp.start() } \ No newline at end of file diff --git a/src/main/kotlin/Note.kt b/src/main/kotlin/Note.kt new file mode 100644 index 00000000..c4a607a6 --- /dev/null +++ b/src/main/kotlin/Note.kt @@ -0,0 +1,2 @@ +class Note(val text: String) { +} \ No newline at end of file diff --git a/src/main/kotlin/NotesApp.kt b/src/main/kotlin/NotesApp.kt new file mode 100644 index 00000000..d7850797 --- /dev/null +++ b/src/main/kotlin/NotesApp.kt @@ -0,0 +1,100 @@ +import java.util.Scanner + +class NotesApp { + var archives = mutableListOf() + var scanner = Scanner(System.`in`) + + fun start() { + while (true) { + println("1. Создать архив") + println("2. Посмотреть архивы") + println("3. Выход") + when(scanner.nextLine().toIntOrNull()){ + 1 -> createArchive() + 2 -> viewArchives() + 3 -> {scanner.close(); return} + else -> println("Неверный ввод. Пожалуйста, введите число от 1 до 3!") + } + } + } + + fun createArchive() { + println("Придумайте название архива: ") + val nameArchive = scanner.nextLine() + if (nameArchive.isBlank()){ + println("Название архива не может быть пустым") + return + } + archives.add(Archive(nameArchive)) + println("Архив $nameArchive создан!") + } + + fun viewArchives() { + if (archives.isEmpty()){ + println("Архив пуст ~~(;-;)~~") + return + } + println("Список архивов") + archives.forEachIndexed { index, archive -> println("${index + 1}. ${archive.name}") } + println("0. Назад") + val inx = scanner.nextLine().toIntOrNull() + if (inx == null || (inx > archives.size)) { // Здесь надо поставить знак > вместо !in + println("Неверный ввод. Пожалуйста, введите число от 0 до ${archives.size }.") + return + } + if (inx == 0){ + return + } + viewArchive(archives[inx - 1]) + } + + fun viewArchive(archive: Archive) { + while (true) { + println("Выберите действие в архиве '${archive.name}':") + println("1. Создать заметку") + println("2. Открыть заметки") + println("3. Назад") + when (scanner.nextLine().toIntOrNull()) { + 1 -> createNote(archive) + 2 -> viewNotes(archive) + 3 -> return + else -> println("Неверный ввод. Пожалуйста, введите число от 1 до 3.") + } + } + } + + fun createNote(archive: Archive) { + println("Введите текст: ") + val textNote = scanner.nextLine() + if (textNote.isBlank()){ + println("Название заметки не может быть пустым") + return + } + archive.noteList.add(Note(textNote)) + println("Заметка создана!\nДля архива ${archive.name}") + } + + fun viewNotes(archive: Archive) { + if (archive.noteList.isEmpty()){ + println("Заметок нет ~~(;-;)~~") + return + } + println("Список заметок: ") + archive.noteList.forEachIndexed { index, note -> println("${index + 1}. ${note.text}") } + println("0. Назад") + val viewNoteIndex = scanner.nextLine().toIntOrNull() + if(viewNoteIndex == null || (viewNoteIndex > archive.noteList.size)){ // Здесь надо поставить знак > вместо !in + println("Неверный ввод. Пожалуйста, введите число от 0 до ${archive.noteList.size}.") + return + } + if (viewNoteIndex == 0) { + return + } + viewNote(archive.noteList[viewNoteIndex - 1]) + } + + fun viewNote(note: Note) { + println(note.text) + } + +} \ No newline at end of file From 1ae9209a682984df77a3b78c0019740944cac0e9 Mon Sep 17 00:00:00 2001 From: SERYOGA-cloud Date: Wed, 25 Jun 2025 01:14:54 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=C2=AB=D0=97=D0=B0=D0=BC=D0=B5=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/Archive.kt | 2 +- src/main/kotlin/Main.kt | 2 +- src/main/kotlin/Note.kt | 2 +- src/main/kotlin/NotesApp.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/Archive.kt b/src/main/kotlin/Archive.kt index b779fcf0..0829b14d 100644 --- a/src/main/kotlin/Archive.kt +++ b/src/main/kotlin/Archive.kt @@ -1,3 +1,3 @@ class Archive(val name: String) { var noteList = mutableListOf() -} \ No newline at end of file +} diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index fd1cb1e5..cd861861 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -1,4 +1,4 @@ fun main(args: Array) { val notesApp = NotesApp() notesApp.start() -} \ No newline at end of file +} diff --git a/src/main/kotlin/Note.kt b/src/main/kotlin/Note.kt index c4a607a6..8df83819 100644 --- a/src/main/kotlin/Note.kt +++ b/src/main/kotlin/Note.kt @@ -1,2 +1,2 @@ class Note(val text: String) { -} \ No newline at end of file +} diff --git a/src/main/kotlin/NotesApp.kt b/src/main/kotlin/NotesApp.kt index d7850797..1fcc0c3f 100644 --- a/src/main/kotlin/NotesApp.kt +++ b/src/main/kotlin/NotesApp.kt @@ -97,4 +97,4 @@ class NotesApp { println(note.text) } -} \ No newline at end of file +} From 8f3c3fe7e1184c1ac4d770ee46a1ccbb7cd14003 Mon Sep 17 00:00:00 2001 From: SERYOGA-cloud Date: Thu, 26 Jun 2025 09:27:11 +0500 Subject: [PATCH 3/3] Update Readme.md --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 996ac25e..7f7d1c0c 100644 --- a/Readme.md +++ b/Readme.md @@ -1 +1 @@ -# Пустой репозиторий для работы с Kotlin кодом в Android Studio +# Заметки