3._create_a_spatializedtree_class
The Java training online
3. Create a SpatializedTree class
Purpose: Explore the class inheritance relationship
Statement of the exercise:
- Create a new class in the same package, named
SpatializedTree
. This class adds two instance variables calledx
andy
, the position of the tree. Write a constructor taking 3 parameters:dbh
,x
andy
. Add a setter forx
andy
, and a getter for each of them. Propose atoString ()
method to displaydbh
,x
andy
. - Add code in the main method of exercise 1. to create a SpatializedTree with dbh 5.6cm and location (2, 1), and print its toString() method to the terminal
3._create_a_spatializedtree_class.txt ยท Last modified: 2021/12/13 09:28 by 127.0.0.1