Skip to Main Content
Android Programming with Kotlin for Beginners
book

Android Programming with Kotlin for Beginners

by John Horton
April 2019
Beginner to intermediate content levelBeginner to intermediate
698 pages
15h 15m
English
Packt Publishing
Content preview from Android Programming with Kotlin for Beginners

Classes using the Inheritance example app

We have looked at the way we can create hierarchies of classes to model the system that fits our app. So, let's build a project to improve upon the naval battle we had in the previous chapter.

Create a new project called Basic Classes with Inheritance Example using the Empty Activity template. As you have come to expect, the completed code can be found in the Chapter11 folder.

This is what we are going to do:

  • Put most of the functionality of the Carrier and Destroyer classes into a Ship super class.
  • Inherit from the Ship class for both Carrier and Destroyer, and therefore save a lot of code maintenance.
  • Use polymorphism to adapt the serviceShip function in the Shipyard class so that it takes Ship as a parameter, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Android with Kotlin

Programming Android with Kotlin

Pierre-Olivier Laurence, Amanda Hinchman-Dominguez, Mike Dunn, G. Blake Meike
How to Build Android Apps with Kotlin - Second Edition

How to Build Android Apps with Kotlin - Second Edition

Alex Forrester, Eran Boudjnah, Alexandru Dumbravan, Jomar Tigcal
Java to Kotlin

Java to Kotlin

Duncan McGregor, Nat Pryce

Publisher Resources

ISBN: 9781789615401Supplemental Content