Загрузка данных


import java.time.LocalDateTime
val openDate = LocalDateTime.now()


class BankAccount(val ownerName: String) {
    var balance = 0
    var isBlocked = false

    fun deposit(amount: Int): Boolean {
        if (isBlocked || amount <= 0) return false
        balance += amount
        return true
    }

    fun withdraw(amount: Int): Boolean {
        if (isBlocked || amount <= 0 || amount > balance) return false
        balance -= amount
        return true
    }

    fun transfer(otherAccount: BankAccount, amount: Int): Boolean {
        if (isBlocked || otherAccount.isBlocked || amount <= 0 || amount > balance) {
            return false
        }
        balance -= amount
        otherAccount.balance += amount
        return true
    }
}

fun main() {
    val account1 = BankAccount("Иван")
    val account2 = BankAccount("Мария")

    println(account1.deposit(1000))
    println(account1.withdraw(300))
    println(account1.transfer(account2, 500))

    println(account1.balance)
    println(account2.balance)
}