July 2018
Intermediate to advanced
400 pages
12h 14m
English
Continue extracting the logic previously defined in the main function into separate functions by using the extract to function feature.
Start by refactoring the logic for the aura color.
Select the code from the line where aura visibility is defined to the end of the if/else condition that checks the Boolean to determine what value to print:
...
// Aura
val auraVisible = isBlessed && healthPoints > 50 || isImmortal
val auraColor = if (auraVisible) "GREEN" else "NONE"
...
Next, select the Extract Function command. You can Control-click (right-click) the selected code and choose Refactor → Extract → Function…, as you did before. You can also use the menus to select Refactor → Extract → Function… Or you can ...
Read now
Unlock full access