Abstraction is the separation between what something does and how it’s accomplished. An interface is a collection of abstract methods and constants that form a common set of base rules/specifications for those classes that implement it. Much like an abstract class, an interface cannot be instantiated and must be implemented by a class.
By having classes implement the interface (as opposed to having them be completely separate standalone classes), we ensure that all classes (and any future classes that implement that interface) will follow the same basic rules. Knowing the rules for the interface allows us to independently write code that uses some features of the interface, regardless of how it’s implemented.
**If we add another method to the interface, we must add an implementation for that method to each class that implements the interface, in order for the code to compile.
My Solution in Java 8:
(Ruby does not formally support interfaces like Java or C#, so this challenge was completed in Java 8. However, interface is a relevant concept to Ruby, which can be read more about here.)
Also, as a side note: When writing multiple classes in the same file, do not use an access modifier (e.g.: public) in your class declaration (or your code will not compile). However, you must use the public access modifier before your method declaration for it to be accessible by the other classes in the file.