Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file added build/classes/kotlin/main/Builder$Stairs.class
Binary file not shown.
Binary file added build/classes/kotlin/main/Builder.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/classes/kotlin/main/Command$Command.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/classes/kotlin/main/Command.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/classes/kotlin/main/Decorator.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/classes/kotlin/main/SingletonLazy.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
5
0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions build/kotlin/homework210SNAPSHOTjar-classes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Builder$Stairs$StairsBuilder.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Builder$Stairs.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Builder.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$BossyTeamCommand.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$CalculateBudgetCommand.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$ClientChatCommand.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$Command.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$CopyDocumentsCommand.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$DummyManager.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$FindResourcesCommand.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command$ManagerInvoker.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Command.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Decorator$BaseMessage.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Decorator$FormattedMessage.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Decorator$TextMessage.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\Decorator.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\SingletonLazy$Singleton$Companion$instance$2.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\SingletonLazy$Singleton$Companion.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\SingletonLazy$Singleton.class;C:\OTUS Android\OtusHomework2\build\classes\kotlin\main\SingletonLazy.class
Binary file added build/libs/homework2-1.0-SNAPSHOT.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions build/tmp/jar/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

8 changes: 8 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Aug 21 21:00:54 MSK 2023
sdk.dir=C\:\\Users\\user\\AppData\\Local\\Android\\Sdk
41 changes: 41 additions & 0 deletions src/main/java/Builder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Builder {

class Stairs(
val numberOfStairs: Int?,
val length: Int?,
val width: Int?,
val height: Int?,
val color: String?,
val floor: Boolean?) {

data class StairsBuilder(
var numberOfStairs: Int? = null,
var length: Int? = null,
var width: Int? = null,
var height: Int? = null,
var color: String? = null,
var floor: Boolean? = false) {

fun numberOfStairs (number: Int) = apply { this.numberOfStairs = number }
fun length (number: Int) = apply { this.length = number }
fun width (number: Int) = apply { this.width = number }
fun height (number: Int) = apply { this.height = number }
fun color(color: String) = apply { this.color = color }
fun floor(floor: Boolean) = apply { this.floor = floor }
fun build() = Stairs(numberOfStairs, length, width, height, color, floor)
}
}

fun main() {
val myStairs = Stairs.StairsBuilder()
.numberOfStairs(3)
.length(150)
.width(30)
.height(18)
.color("brown")
.floor(true)
.build()
}


}
71 changes: 71 additions & 0 deletions src/main/java/Command.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
class Command {

interface Command {
fun execute()
}

class DummyManager {
fun copyDocuments() {
println("Снова эти бумажки...") }

fun bossyTeam() {
println("Какие проблемы? Когда будет готово?") }

fun clientChat() {
println("Да-да, завтра всё сделаем.") }

fun findResouces() {
println("Мне бы еще одного разработчика...") }

fun calculateBudget() {
println("Опять денег нет!") }
}

class CopyDocumentsCommand(private val dummyManager: DummyManager) : Command {
override fun execute() {
dummyManager.copyDocuments()
}
}
class BossyTeamCommand(private val dummyManager: DummyManager) : Command {
override fun execute() {
dummyManager.bossyTeam()
}
}
class ClientChatCommand(private val dummyManager: DummyManager) : Command {
override fun execute() {
dummyManager.clientChat()
}
}
class FindResourcesCommand(private val dummyManager: DummyManager) : Command {
override fun execute() {
dummyManager.findResouces()
}
}
class CalculateBudgetCommand(private val dummyManager: DummyManager) : Command {
override fun execute() {
dummyManager.calculateBudget()
}
}

class ManagerInvoker {
private val commands = mutableListOf<Command>()

fun executeCommand(command: Command) {
commands.add(command)
command.execute()
}
}


fun main() {
val manager = DummyManager()
val invoker = ManagerInvoker()

invoker.executeCommand(CopyDocumentsCommand(manager))
invoker.executeCommand(BossyTeamCommand(manager))
invoker.executeCommand(ClientChatCommand(manager))
invoker.executeCommand(FindResourcesCommand(manager))
invoker.executeCommand(CalculateBudgetCommand(manager))
}

}
35 changes: 35 additions & 0 deletions src/main/java/Decorator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import org.w3c.dom.Text

class Decorator {

interface TextMessage {
fun baseMessage()
}

class BaseMessage : TextMessage {
override fun baseMessage() {
println("Just an ordinary message")
}
}


class FormattedMessage (val textMessage: TextMessage) : TextMessage {

fun formattedMessage() {
println("HeRe's a FoRmAtTeD mEsSaGe")
}

override fun baseMessage() {
println("Here's how an ORDINARY MESSAGE looks like now!")
}
}

fun main() {
val baseMessage = BaseMessage()
val formattedMessage = FormattedMessage(baseMessage)

formattedMessage.baseMessage()
formattedMessage.formattedMessage()
}

}
23 changes: 23 additions & 0 deletions src/main/java/SingletonLazy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class SingletonLazy {

class Singleton private constructor() {

fun singletonCreated () {
println("Singleton instance created")
}

companion object {
val instance:Singleton by lazy {
Singleton()
}
}


}

fun main() {
val instance = Singleton.instance
}


}