solution_of_4._add_instance_variables_in_the_tree
The Java training online
Solution: 4. Add instance variables in the tree
Try to work with the helping elements before looking at the solution…
Helping elements
- to be available in
Tree
and inSpatializedTree
, the new variables should be added in the superclass:Tree
: they will be inherited in the subclass.
- the three getters should be added in the same class,
getId ()
…
- you may adapt the constructor of Tree to get the 3 extra parameters and store them in the 3 new instance variables like for
dbh
- the
toString ()
method ofTree
may be adapted to display the 4 instance variables
- the
toString ()
method ofSpatializedTree
relying on its superclass needs no change
- the code of exercice 1. needs adaptation to match the new constructor of
Tree
with its 4 parameters
A possible solution
solution_of_4._add_instance_variables_in_the_tree.txt · Last modified: 2021/12/13 09:28 by 127.0.0.1