joshua-r2
10/26/2017 - 7:33 PM

Abstract Class

An abstract class or method does not have an implementation method. They are essentially "kicking the can downt he road" to any inheriting subclasses



class CommunityRugby: RecreationalActivity(){

  override fun locationOfActivity(place: String){
  
    println("Painfully located at ${place}")
  
  }

}

//The base class
open class Activity{

  open fun locationOfActivity(place: String){
    println("${place}")
  }

}

//In this class, we are going to pass the locationOfActivity to subclasses because 
//Recreational Activities can be done inside or outside and there is no point in
//specifying here

abstract class RecreationalActivity: Activity(){

  //Notice there is no implementation of the overriden method
  override abstract fun locationOfActivity(place: String)

  fun commitmentLevel: String { return "Recreational" }
  
}