Refactoring NyetHack

You have learned about class functions, properties, and encapsulation, and you have done some of the work to apply these concepts to NyetHack. It is time to finish the job and thoroughly clean up NyetHack’s code.

You will be moving chunks of code from one file to another. It helps to see the two files side by side. Fortunately, IntelliJ provides this feature.

With Game.kt open, right-click on the Player.kt tab at the top of the editor and select Split Vertically (Figure 12.3).

Figure 12.3  Splitting the editor vertically

Splitting the editor vertically

You now have another editor pane to work in (Figure 12.4). (You can drag tabs between ...

Get Kotlin Programming: The Big Nerd Ranch Guide, First 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.