July 2017
Intermediate to advanced
796 pages
18h 55m
English
Classes are considered as a blueprint and then you instantiate this class in order to create something that will actually be represented in memory. They can contain methods, values, variables, types, objects, traits, and classes which are collectively called members. Let's demonstrate this with the following example:
class Animal { var animalName = null var animalAge = -1 def setAnimalName (animalName:String) { this.animalName = animalName } def setAnaimalAge (animalAge:Int) { this.animalAge = animalAge } def getAnimalName () : String = { animalName } def getAnimalAge () : Int = { animalAge }}
We have two variables animalName and animalAge with their setters and getters. Now, how do we use them to solve our purpose? Here ...
Read now
Unlock full access