This SKB is going to continue our progress in the Object Oriented Programming aspect of Scala.
abstract class are pretty similar to
trait we saw before. But there are some slight differences.
You recognize the same keywords we learned about when we learned about
trait. You can see
There are more differences but for the moment let’s go one step at a time.
The main difference you can notice compare to
trait is that you are able to have a constructor directly when you
abstract class. This is pretty convenient to build simple pattern. We are going to see more about this in the context of
To practice the concepts of Object Oriented Programming, Try to access the fields of
Shape in the child classes. You notice that only
protected and not the other ones. Remember
class ? By default fields are
private in a
class. Try to add methods, maybe the area ?