TheBulgarianWolf

Kotlin Secondary Constructor

Apr 1st, 2021
1,003
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main(args: Array<String>) {
  2.  
  3.     val p1 = AuthLog("Bad Password")
  4. }
  5.  
  6. open class Log {
  7.     var data: String = ""
  8.     var numberOfData = 0
  9.     constructor(_data: String) {
  10.  
  11.     }
  12.     constructor(_data: String, _numberOfData: Int) {
  13.         data = _data
  14.         numberOfData = _numberOfData
  15.         println("$data: $numberOfData times")
  16.     }
  17. }
  18.  
  19. class AuthLog: Log {
  20.     constructor(_data: String): this("From AuthLog -> " + _data, 10) {
  21.     }
  22.  
  23.     constructor(_data: String, _numberOfData: Int): super(_data, _numberOfData) {
  24.     }
  25. }
RAW Paste Data