2 - OOP in Scala
Today we review OOP principles and apply them in Scala.
We also show why Scala is more OO than Java :)
You can find today's contents here.
Practice
You can create a simple project, with a single Scala file. Call it whatever you like.
Along with the main method, you can create a method for every exercise.
A simple class - Define a simple class Car that has two fields speed and weight and a method accelerate
Car Factory - Assume you have the abstract class Car which is extended by SuperCar and MuscleCar
Companions - Instead of defining a separate CarFactory, refactor the previous solution and move the getCar method within the Car's companion object. Companions are usually used to define constants or methods resembling the static ones in Java.