Advertisement
zemf4you

Untitled

Jan 29th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.98 KB | None | 0 0
  1. open class Letter(hash: BigInteger, var lineHeight: Int) {
  2.     var pixels: Int = countBinaryOnes(hash)
  3.     var hash: BigInteger = hash
  4.     set(value) {
  5.         pixels = countBinaryOnes(hash)
  6.         field = value
  7.     }
  8. }
  9.  
  10. class DeterminedLetter(val char: Char, hash: BigInteger, lineHeight: Int): Letter(hash, lineHeight) {
  11.     private class Params(val char: Char, val hash: BigInteger, val lineHeight: Int)
  12.     private constructor(params: Params): this(params.char, params.hash, params.lineHeight)
  13.     constructor(line: String): this(constructFromString(line))
  14.     constructor(char: Char, letter: Letter): this(char, letter.hash, letter.lineHeight)
  15.     companion object {
  16.         private fun constructFromString(line: String): Params {
  17.             val pair = line.split(',')
  18.             val char = pair[0].toInt().toChar()
  19.             val lineHeight = pair[1].toInt()
  20.             val hash = pair[2].toBigInteger()
  21.             return Params(char, hash, lineHeight)
  22.         }
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement