User Tools

Site Tools


4._add_instance_variables_in_the_tree

The Java training online

Back to the table of contents

4. Add instance variables in the tree

Purpose: Think and find where new instance variables should be added in an inheritance graph

Statement of the exercise:

  1. Add 3 instances variables in the tree classes: int id, int age and double height (m). Add getters for them 3, no setters required here.
  2. Add code in the main method of exercise 1. to create a SpatializedTree with id = 2, age = 6, height = 6.7m, dbh= 6.1cm and location (4, 3), then print its toString() method to the terminal

Helper and solution

Back to the table of contents

4._add_instance_variables_in_the_tree.txt ยท Last modified: 2021/12/13 09:28 by 127.0.0.1