Abstract Classes
Abstract classes provide another way to enforce structure in your classes. An abstract class is never directly instantiated. Its purpose is to provide function implementations through inheritance to subclasses that are instantiated.
An abstract class is defined by prepending the abstract
keyword to a class definition.
In addition to function implementations, abstract classes can include abstract functions – function declarations without implementations.
It is time to give the player something to fight in NyetHack. Add an abstract class called Monster to Creature.kt. Monster implements the Fightable interface, and therefore needs name and healthPoints properties and a takeDamage function. (What about the other ...
Get Kotlin Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.