solution_of_5._add_methods_in_the_tree
The Java training online
Solution: 5. Add methods in the tree
Try to work with the helping elements before looking at the solution…
Helping elements
- the 2 methods should be added in
Tree
, they will be inherited and available inSpatializedTree
- These 2 methods rely on existing instance variables, so no new instance variable is needed
- to avoid an integer division in
getCrownBaseHeight()
, make sure to write2d / 3d
(if the 2 operands of a division are integers, only the integer part is kept in the result:2 / 3 = 1
, but2d / 3d = 1.5
)
- adapt
toString ()
inTree
to display thecrownRadius
andcrownBaseHeight
values
- use
NumberFormat
to display1.12
instead of1.119999999999
, see the online javadoc for NumberFormat, try to have the english.
decimal separator
A possible solution
solution_of_5._add_methods_in_the_tree.txt · Last modified: 2021/12/13 09:28 by 127.0.0.1