Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
OO Catastrophe!
Defines behavior
Contract
Cannot be instantiated
A class can implement multiple interfaces
Abstract class
Defines behavior Can have implementation code Cannot be instantiated A class can inherit from a single abstract class
How do I know when to use an interface and when to use an abstract class?
If (almost) all classes implementing the behavior would have the same code, then you can use an abstract class to implement it.
Program to interfaces
ENCAPSULATION
Isnt encapsulation just about hiding implementation?
Solution 1
Solution 2
10
11
12
Our solution
13